From: cassowarii Date: Wed, 24 Jun 2026 03:03:06 +0000 (-0700) Subject: fix a couple more bugs with string allocation X-Git-Url: https://git.cassowary.me/gitweb.cgi?a=commitdiff_plain;h=438062421fea1adf523cab33fc5ebc9f5fb12054;p=sarabande.git fix a couple more bugs with string allocation --- diff --git a/src/data/string.c b/src/data/string.c index 8d1c0a4..be9bd1c 100644 --- a/src/data/string.c +++ b/src/data/string.c @@ -181,7 +181,7 @@ static strentry *alloc_entry(strblk *blk) { do { next_free_index ++; next_free_index %= STRINGS_PER_BLOCK; - } while (blk->entries[free_index].allocated && next_free_index != blk->next_free_index); + } while (blk->entries[next_free_index].allocated && next_free_index != blk->next_free_index); if (next_free_index == blk->next_free_index) { PANIC("free count lied! for strblk (#%zu)", blk->id); @@ -259,7 +259,7 @@ static void place_str_at_offset(strentry *e, usize offset, const char *str, usiz static strentry *new_entry(usize length) { strblk *new_block = find_free_block(); strentry *new_entry = alloc_entry(new_block); - new_entry->handle = new_block->id * STRINGS_PER_BLOCK + (new_entry - new_block->entries) / sizeof(strentry); + new_entry->handle = new_block->id * STRINGS_PER_BLOCK + (new_entry - new_block->entries); set_entry_size(new_entry, length); return new_entry; }