Laika/lib/src/core/lmem.c

21 lines
396 B
C
Raw Normal View History

2022-09-02 01:00:37 +00:00
#include "core/lmem.h"
2022-09-02 01:00:37 +00:00
#include "core/lerror.h"
void *laikaM_realloc(void *buf, size_t sz)
{
void *newBuf;
/* are we free'ing the buffer? */
if (sz == 0) {
2022-04-08 04:21:09 +00:00
free(buf);
return NULL;
}
/* if NULL is passed, realloc() acts like malloc() */
if ((newBuf = realloc(buf, sz)) == NULL)
LAIKA_ERROR("failed to allocate memory!\n");
return newBuf;
2022-04-08 04:21:09 +00:00
}