2015-04-28 12:49:20 -05:00
|
|
|
// 4 december 2014
|
|
|
|
#import <stdio.h>
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2015-05-03 18:52:24 -05:00
|
|
|
void *uiAlloc(size_t size)
|
2015-04-28 12:49:20 -05:00
|
|
|
{
|
|
|
|
void *out;
|
|
|
|
|
|
|
|
out = malloc(size);
|
|
|
|
if (out == NULL) {
|
2015-05-03 18:58:12 -05:00
|
|
|
fprintf(stderr, "memory exhausted in uiAlloc()\n");
|
2015-04-28 12:49:20 -05:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
memset(out, 0, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2015-05-03 18:52:24 -05:00
|
|
|
void *uiRealloc(void *p, size_t size)
|
2015-04-28 12:49:20 -05:00
|
|
|
{
|
|
|
|
void *out;
|
|
|
|
|
|
|
|
if (p == NULL)
|
2015-05-03 18:52:24 -05:00
|
|
|
return uiAlloc(size);
|
2015-04-28 12:49:20 -05:00
|
|
|
out = realloc(p, size);
|
|
|
|
if (out == NULL) {
|
2015-05-03 18:58:12 -05:00
|
|
|
fprintf(stderr, "memory exhausted in uiRealloc()\n");
|
2015-04-28 12:49:20 -05:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
// TODO zero the extra memory
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiFree(void *p)
|
|
|
|
{
|
|
|
|
if (p == NULL)
|
|
|
|
return;
|
|
|
|
free(p);
|
|
|
|
}
|