2015-04-06 18:04:13 -05:00
|
|
|
// 4 december 2014
|
|
|
|
#include "ui_darwin.h"
|
|
|
|
|
2015-04-06 19:01:14 -05:00
|
|
|
// TODO is there a better alternative to NSCAssert()? preferably a built-in allocator that panics on out of memory for us?
|
|
|
|
|
2015-04-06 18:04:13 -05:00
|
|
|
void *uiAlloc(size_t size)
|
|
|
|
{
|
|
|
|
void *out;
|
|
|
|
|
|
|
|
out = malloc(size);
|
2015-04-06 19:01:14 -05:00
|
|
|
NSCAssert(out != NULL, @"out of memory in uiAlloc()");
|
2015-04-06 18:04:13 -05:00
|
|
|
memset(out, 0, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *uiRealloc(void *p, size_t size)
|
|
|
|
{
|
|
|
|
void *out;
|
|
|
|
|
|
|
|
if (p == NULL)
|
|
|
|
return uiAlloc(size);
|
|
|
|
out = realloc(p, size);
|
2015-04-06 19:01:14 -05:00
|
|
|
NSCAssert(out != NULL, @"out of memory in uiRealloc()");
|
2015-04-06 18:04:13 -05:00
|
|
|
// TODO zero the extra memory
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiFree(void *p)
|
|
|
|
{
|
|
|
|
if (p == NULL)
|
|
|
|
return;
|
|
|
|
free(p);
|
|
|
|
}
|