diff --git a/src/util.c b/src/util.c index 47c0e92a..9bae147f 100644 --- a/src/util.c +++ b/src/util.c @@ -31,7 +31,7 @@ void lovrThrow(const char* format, ...) { void* _lovrAlloc(const char* type, size_t size, void (*destructor)(void*)) { Ref* ref = calloc(1, size); if (!ref) return lovrThrow("Out of memory"), NULL; - ref->free = destructor; + ref->destructor = destructor; ref->type = type; ref->count = 1; return ref; @@ -43,7 +43,9 @@ void lovrRetain(void* object) { void lovrRelease(void* object) { Ref* ref = object; - if (ref && --ref->count == 0) ref->free(object); + if (ref && --ref->count == 0) { + ref->destructor(object); + } } // https://github.com/starwing/luautf8 diff --git a/src/util.h b/src/util.h index ded9fed0..27e4c5cf 100644 --- a/src/util.h +++ b/src/util.h @@ -31,7 +31,7 @@ #define ALIGN(p, n) ((uintptr_t) p & -n) typedef struct ref { - void (*free)(void*); + void (*destructor)(void*); const char* type; int count; } Ref;