Minor cleanup

This commit is contained in:
Nils O. Selåsdal
2026-04-21 23:01:22 +02:00
parent d1a45cf8e0
commit d58e24f6a9
2 changed files with 7 additions and 9 deletions
+6 -5
View File
@@ -5,9 +5,10 @@
#include <assert.h>
//Free memory is reused to build a linked list of slots
typedef struct UCSlot UCSlot;
struct UCSlot {
UCSlot *next;
typedef union UCSlot UCSlot;
union UCSlot {
UCSlot *next; // next free block (when not allocated)
uint8_t data[0]; // data when allocated
};
typedef struct UCSlotArena UCSlotArena;
@@ -71,7 +72,7 @@ static inline void *uc_slot_alloc(UCSlotArena *arena)
#endif
}
return slot;
return &slot->data[0];
}
/**
* Free a slot.
@@ -84,7 +85,7 @@ static inline void uc_slot_free(UCSlotArena *arena, void *memory)
#ifdef DEBUG
for (const UCSlot *slot = arena->free_list ; slot = slot->next) {
if (slot == mem) {
assert("Double free detected");
assert(0 && "Double free detected");
}
}
#endif