aboutsummaryrefslogtreecommitdiff
path: root/builtins/table.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-17 19:32:30 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-17 19:32:30 -0500
commitd46925dbfa8627a6a874545630c2acb6975bfdea (patch)
tree2b726ea50adf91b668a24b25d4d9e6ec7f7c2663 /builtins/table.c
parent7355b2f7fe6f5dda2aee8feca025350146ccd0f5 (diff)
Cleanup of builtins
Diffstat (limited to 'builtins/table.c')
-rw-r--r--builtins/table.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtins/table.c b/builtins/table.c
index ad8c6e4c..6db29186 100644
--- a/builtins/table.c
+++ b/builtins/table.c
@@ -40,7 +40,7 @@
#define END_OF_CHAIN UINT32_MAX
#define GET_ENTRY(t, i) ((t)->entries.data + (t)->entries.stride*(i))
-#define ENTRY_TYPE(type) (&(TypeInfo){.size=entry_size(type), .align=entry_align(type), .tag=OpaqueInfo})
+#define ENTRIES_TYPE(type) (&(TypeInfo){.size=sizeof(array_t), .align=alignof(array_t), .tag=ArrayInfo, .ArrayInfo.item=(&(TypeInfo){.size=entry_size(type), .align=entry_align(type), .tag=OpaqueInfo})})
extern const void *SSS_HASH_VECTOR;
@@ -102,7 +102,7 @@ static inline void hshow(const table_t *t)
static void maybe_copy_on_write(table_t *t, const TypeInfo *type)
{
if (t->entries.copy_on_write) {
- Array__compact(&t->entries, ENTRY_TYPE(type));
+ Array__compact(&t->entries, ENTRIES_TYPE(type));
}
if (t->bucket_info && t->bucket_info->copy_on_write) {
@@ -279,7 +279,7 @@ public void *Table_reserve(table_t *t, const void *key, const void *value, const
memcpy(buf + value_offset(type), value, value_size);
else
memset(buf + value_offset(type), 0, value_size);
- Array__insert(&t->entries, buf, 0, ENTRY_TYPE(type));
+ Array__insert(&t->entries, buf, 0, ENTRIES_TYPE(type));
int64_t entry_index = t->entries.length-1;
void *entry = GET_ENTRY(t, entry_index);
@@ -365,7 +365,7 @@ public void Table_remove(table_t *t, const void *key, const TypeInfo *type)
// Last entry is being removed, so clear it out to be safe:
memset(GET_ENTRY(t, last_entry), 0, entry_size(type));
- Array__remove(&t->entries, t->entries.length, 1, ENTRY_TYPE(type));
+ Array__remove(&t->entries, t->entries.length, 1, ENTRIES_TYPE(type));
int64_t bucket_to_clear;
if (prev) { // Middle (or end) of a chain