new module for memory allocation

This commit is contained in:
Roberto Ierusalimschy
1994-11-16 15:39:16 -02:00
parent 94686ce585
commit 2b5bc5d1a8
9 changed files with 114 additions and 100 deletions

35
luamem.c Normal file
View File

@@ -0,0 +1,35 @@
/*
** mem.c
** TecCGraf - PUC-Rio
*/
char *rcs_mem = "$Id: $";
#include <stdlib.h>
#include "mem.h"
#include "lua.h"
void luaI_free (void *block)
{
free(block);
}
void *luaI_malloc (unsigned long size)
{
void *block = malloc(size);
if (block == NULL)
lua_error("not enough memory");
return block;
}
void *luaI_realloc (void *oldblock, unsigned long size)
{
void *block = realloc(oldblock, size);
if (block == NULL)
lua_error("not enough memory");
return block;
}