mirror of https://github.com/bjornbytes/lovr.git
mv ref->free ref->destructor;
This commit is contained in:
parent
4c9b02a6ff
commit
5b52a91778
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue