Mercurial > hg-old > index.cgi
changeset 20:610710a7859f
added lwasm_realloc()
author | lost |
---|---|
date | Fri, 02 Jan 2009 00:42:11 +0000 |
parents | 925105ccf22f |
children | 3c0e5f311c95 |
files | src/util.c src/util.h |
diffstat | 2 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/util.c Fri Jan 02 00:41:58 2009 +0000 +++ b/src/util.c Fri Jan 02 00:42:11 2009 +0000 @@ -45,6 +45,24 @@ return ptr; } +void *lwasm_realloc(void *optr, int size) +{ + void *ptr; + + if (size == 0) + { + lwasm_free(optr); + return; + } + + ptr = realloc(optr, size); + if (!ptr) + { + fprintf(stderr, "lwasm_realloc(): memory allocation error\n"); + exit(1); + } +} + void lwasm_free(void *ptr) { if (ptr)
--- a/src/util.h Fri Jan 02 00:41:58 2009 +0000 +++ b/src/util.h Fri Jan 02 00:42:11 2009 +0000 @@ -34,6 +34,7 @@ // allocate memory __util_E__ void *lwasm_alloc(int size); __util_E__ void lwasm_free(void *ptr); +__util_E__ void *lwasm_realloc(void *optr, int size); // string stuff __util_E__ char *lwasm_strdup(const char *s);