diff options
Diffstat (limited to 'stdlib')
| -rw-r--r-- | stdlib/arrays.c | 2 | ||||
| -rw-r--r-- | stdlib/patterns.c | 10 | ||||
| -rw-r--r-- | stdlib/stdlib.c | 6 | ||||
| -rw-r--r-- | stdlib/structs.c | 2 | ||||
| -rw-r--r-- | stdlib/text.c | 9 | ||||
| -rw-r--r-- | stdlib/threads.c | 2 |
6 files changed, 21 insertions, 10 deletions
diff --git a/stdlib/arrays.c b/stdlib/arrays.c index 41d46741..cd403c5f 100644 --- a/stdlib/arrays.c +++ b/stdlib/arrays.c @@ -348,7 +348,7 @@ public Array_t Array$sample(Array_t arr, Int_t int_n, Array_t weights, RNG_t rng struct { int64_t alias; double odds; - } aliases[arr.length] = {}; + } aliases[arr.length]; for (int64_t i = 0; i < arr.length; i++) { double weight = i >= weights.length ? 0.0 : *(double*)(weights.data + weights.stride*i); diff --git a/stdlib/patterns.c b/stdlib/patterns.c index 7a165836..7f7d711b 100644 --- a/stdlib/patterns.c +++ b/stdlib/patterns.c @@ -1267,10 +1267,18 @@ public const TypeInfo_t Pattern$info = { .metamethods=Text$metamethods, }; +static const TypeInfo_t _text_array = { + .size=sizeof(Array_t), + .align=__alignof__(Array_t), + .tag=ArrayInfo, + .ArrayInfo.item=&Text$info, + .metamethods=Array$metamethods, +}; + static NamedType_t _match_fields[3] = { {"text", &Text$info}, {"index", &Int$info}, - {"captures", Array$info(&Text$info)}, + {"captures", &_text_array}, }; static bool Match$is_none(const void *m, const TypeInfo_t*) diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c index 9b117a24..9103e4dd 100644 --- a/stdlib/stdlib.c +++ b/stdlib/stdlib.c @@ -224,8 +224,10 @@ static Table_t parse_table(const TypeInfo_t *table, int n, char *args[]) #pragma GCC diagnostic ignored "-Wstack-protector" public void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len]) { - bool populated_args[spec_len] = {}; - bool used_args[argc] = {}; + bool populated_args[spec_len]; + bool used_args[argc]; + memset(populated_args, 0, sizeof(populated_args)); + memset(used_args, 0, sizeof(used_args)); for (int i = 1; i < argc; ) { if (argv[i][0] == '-' && argv[i][1] == '-') { if (argv[i][2] == '\0') { // "--" signals the rest of the arguments are literal diff --git a/stdlib/structs.c b/stdlib/structs.c index 0b1385ee..ca88262c 100644 --- a/stdlib/structs.c +++ b/stdlib/structs.c @@ -24,7 +24,7 @@ PUREFUNC public uint64_t Struct$hash(const void *obj, const TypeInfo_t *type) if (type->StructInfo.num_fields == 1) return generic_hash(obj, type->StructInfo.fields[0].type); - uint64_t field_hashes[type->StructInfo.num_fields] = {}; + uint64_t field_hashes[type->StructInfo.num_fields]; ptrdiff_t byte_offset = 0; ptrdiff_t bit_offset = 0; for (int i = 0; i < type->StructInfo.num_fields; i++) { diff --git a/stdlib/text.c b/stdlib/text.c index 9abab57b..966f6ac3 100644 --- a/stdlib/text.c +++ b/stdlib/text.c @@ -138,7 +138,7 @@ static const TypeInfo_t GraphemeClusterInfo = { #pragma GCC diagnostic ignored "-Wstack-protector" public int32_t get_synthetic_grapheme(const ucs4_t *codepoints, int64_t utf32_len) { - ucs4_t length_prefixed[1+utf32_len] = {}; + ucs4_t length_prefixed[1+utf32_len]; length_prefixed[0] = (ucs4_t)utf32_len; for (int i = 0; i < utf32_len; i++) length_prefixed[i+1] = codepoints[i]; @@ -330,7 +330,8 @@ static void insert_balanced_recursive(Text_t balanced_texts[MAX_TEXT_DEPTH], Tex static Text_t rebalanced(Text_t a, Text_t b) { - Text_t balanced_texts[MAX_TEXT_DEPTH] = {}; + Text_t balanced_texts[MAX_TEXT_DEPTH]; + memset(balanced_texts, 0, sizeof(balanced_texts)); insert_balanced_recursive(balanced_texts, a); insert_balanced_recursive(balanced_texts, b); @@ -436,7 +437,7 @@ static Text_t concat2(Text_t a, Text_t b) size_t len = (last_a >= 0) ? 1 : NUM_GRAPHEME_CODEPOINTS(last_a); len += (first_b >= 0) ? 1 : NUM_GRAPHEME_CODEPOINTS(first_b); - ucs4_t codepoints[len] = {}; + ucs4_t codepoints[len]; ucs4_t *dest = codepoints; if (last_a < 0) dest = mempcpy(dest, GRAPHEME_CODEPOINTS(last_a), sizeof(ucs4_t[NUM_GRAPHEME_CODEPOINTS(last_a)])); @@ -451,7 +452,7 @@ static Text_t concat2(Text_t a, Text_t b) // Do a normalization run for these two codepoints and see if it looks different. // Normalization should not exceed 3x in the input length (but if it does, it will be // handled gracefully) - ucs4_t norm_buf[3*len] = {}; + ucs4_t norm_buf[3*len]; size_t norm_length = sizeof(norm_buf)/sizeof(norm_buf[0]); ucs4_t *normalized = u32_normalize(UNINORM_NFC, codepoints, len, norm_buf, &norm_length); bool stable = (norm_length == len && memcmp(codepoints, normalized, sizeof(codepoints)) == 0); diff --git a/stdlib/threads.c b/stdlib/threads.c index efd23546..9ad68c81 100644 --- a/stdlib/threads.c +++ b/stdlib/threads.c @@ -33,7 +33,7 @@ static void *run_thread(Closure_t *closure) public Thread_t Thread$new(Closure_t fn) { - Thread_t thread = new(pthread_t); + Thread_t thread = GC_MALLOC(sizeof(pthread_t)); Closure_t *closure = new(Closure_t, .fn=fn.fn, .userdata=fn.userdata); pthread_create(thread, NULL, (void*)run_thread, closure); return thread; |
