diff options
author | Lua Team <team@lua.org> | 1995-02-07 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 1995-02-07 12:00:00 +0000 |
commit | a8b6ba0954edb9e0e669e1f451b9a8f145ce5166 (patch) | |
tree | 35e9e9999968c4f13a25a5f647203456f044274a /src/mem.c | |
parent | 944fc7d7d95575f2b8023c1f3d4ac19e1369fc76 (diff) | |
download | lua-github-2.1.tar.gz |
Lua 2.12.1
Diffstat (limited to 'src/mem.c')
-rw-r--r-- | src/mem.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/mem.c b/src/mem.c new file mode 100644 index 00000000..90369720 --- /dev/null +++ b/src/mem.c @@ -0,0 +1,44 @@ +/* +** mem.c +** TecCGraf - PUC-Rio +*/ + +char *rcs_mem = "$Id: mem.c,v 1.5 1995/02/06 19:34:03 roberto Exp $"; + +#include <stdlib.h> +#include <string.h> + +#include "mem.h" +#include "lua.h" + +void luaI_free (void *block) +{ + *((int *)block) = -1; /* to catch errors */ + free(block); +} + + +void *luaI_malloc (unsigned long size) +{ + void *block = malloc((size_t)size); + if (block == NULL) + lua_error("not enough memory"); + return block; +} + + +void *luaI_realloc (void *oldblock, unsigned long size) +{ + void *block = realloc(oldblock, (size_t)size); + if (block == NULL) + lua_error("not enough memory"); + return block; +} + + +char *luaI_strdup (char *str) +{ + char *newstr = luaI_malloc(strlen(str)+1); + strcpy(newstr, str); + return newstr; +} |