diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-06 15:05:35 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-06 15:05:35 -0400 |
| commit | e9abf8a370b0256f96108048eec95b68ef92effc (patch) | |
| tree | 5987fc28bc90605a7f6e6fa57fbc9da3b1d8deac /builtins/table.c | |
| parent | b4dc8587946d5300ae983c9c3cfc2d03f76ed746 (diff) | |
Prefer 'sizeof(t[n])' over 'sizeof(t)*n'
Diffstat (limited to 'builtins/table.c')
| -rw-r--r-- | builtins/table.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/builtins/table.c b/builtins/table.c index 591acc96..6b63be8d 100644 --- a/builtins/table.c +++ b/builtins/table.c @@ -102,7 +102,7 @@ static void maybe_copy_on_write(table_t *t, const TypeInfo *type) } if (t->bucket_info && t->bucket_info->data_refcount) { - int64_t size = sizeof(bucket_info_t) + t->bucket_info->count*sizeof(bucket_t); + int64_t size = sizeof(bucket_info_t) + sizeof(bucket_t[t->bucket_info->count]); t->bucket_info = memcpy(GC_MALLOC(size), t->bucket_info, size); t->bucket_info->data_refcount = 0; } @@ -208,9 +208,9 @@ static void hashmap_resize_buckets(table_t *t, uint32_t new_capacity, const Type { hdebug("About to resize from %u to %u\n", t->bucket_info ? t->bucket_info->count : 0, new_capacity); hshow(t); - int64_t alloc_size = sizeof(bucket_info_t) + (int64_t)(new_capacity)*sizeof(bucket_t); + int64_t alloc_size = sizeof(bucket_info_t) + sizeof(bucket_t[new_capacity]); t->bucket_info = GC_MALLOC_ATOMIC(alloc_size); - memset(t->bucket_info->buckets, 0, (int64_t)new_capacity * sizeof(bucket_t)); + memset(t->bucket_info->buckets, 0, sizeof(bucket_t[new_capacity])); t->bucket_info->count = new_capacity; t->bucket_info->last_free = new_capacity-1; // Rehash: |
