mirror of https://github.com/bjornbytes/lovr.git
_lovrAlloc throws on OOM;
This commit is contained in:
parent
ab8e86b9a5
commit
58950aa20e
10
src/util.c
10
src/util.c
|
@ -29,10 +29,12 @@ void lovrThrow(const char* format, ...) {
|
|||
}
|
||||
|
||||
void* _lovrAlloc(const char* type, size_t size, void (*destructor)(void*)) {
|
||||
void* object = calloc(1, size);
|
||||
if (!object) return NULL;
|
||||
*((Ref*) object) = (Ref) { .free = destructor, .type = type, .count = 1 };
|
||||
return object;
|
||||
Ref* ref = calloc(1, size);
|
||||
if (!ref) return lovrThrow("Out of memory"), NULL;
|
||||
ref->free = destructor;
|
||||
ref->type = type;
|
||||
ref->count = 1;
|
||||
return ref;
|
||||
}
|
||||
|
||||
void lovrRetain(void* object) {
|
||||
|
|
Loading…
Reference in New Issue