add fake struct to help with type checker

This commit is contained in:
Peter McGoron 2024-06-13 21:01:03 -04:00
parent 3d7e39cfd2
commit 5b8775dab6
2 changed files with 11 additions and 3 deletions

View File

@ -174,7 +174,7 @@ void uns_hashtable_add(struct uns_gc *gc, struct uns_ctr *htbl,
if (uns_hashtable_used(gc, htbl) >= uns_hashtable_len(gc, htbl)*7/10)
uns_hashtable_resize(gc, htbl, uns_hashtable_len(gc, htbl)*2);
if (search_for_container(gc, htbl, &container, string->p, string_len, &hash)) {
if (search_for_container(gc, htbl, &container, (unsigned char *)string->p, string_len, &hash)) {
old_value->p = gc->record_get_ptr(container.p, VALUE);
gc->record_set_ptr(container.p, VALUE, value->p);
return;

View File

@ -38,6 +38,14 @@
typedef UNS_WORD uns_word;
typedef UNS_SIGNED_WORD uns_sword;
/* This struct doesn't exist and is used to make a unique pointer for
* type checking.
*
* This pointer must be what was returned from an allocation (i.e. it points
* to the first byte but before any hidden header data).
*/
typedef struct uns_ptr *Uns_ptr;
/** Doubly linked list used to
*
* 1) Store roots of the GC,
@ -89,8 +97,8 @@ struct uns_gc {
*/
size_t (*len)(void *);
void (*record_set_ptr)(void *, size_t, void *);
void *(*record_get_ptr)(void *, size_t);
void (*record_set_ptr)(Uns_ptr, size_t, void *);
void *(*record_get_ptr)(Uns_ptr, size_t);
};
/** Add a root to the GC. The root must point to valid memory, or NULL. */