From 7236df875aa62e3e217e676365738ae5a0308a9b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 14 Mar 1996 12:55:49 -0300 Subject: [PATCH] new function "luaI_buffer". --- luamem.c | 12 +++++++++++- luamem.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/luamem.c b/luamem.c index ef4eae29..eeceaea2 100644 --- a/luamem.c +++ b/luamem.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_mem = "$Id: mem.c,v 1.7 1996/02/04 16:59:12 roberto Exp roberto $"; +char *rcs_mem = "$Id: mem.c,v 1.8 1996/02/22 20:34:33 roberto Exp roberto $"; #include #include @@ -53,3 +53,13 @@ void *luaI_realloc (void *oldblock, unsigned long size) return block; } + +void* luaI_buffer (unsigned long size) +{ + static unsigned long buffsize = 0; + static char* buffer = NULL; + if (size > buffsize) + buffer = luaI_realloc(buffer, buffsize=size); + return buffer; +} + diff --git a/luamem.h b/luamem.h index 06687efc..57e8f2d9 100644 --- a/luamem.h +++ b/luamem.h @@ -1,7 +1,7 @@ /* ** mem.c ** memory manager for lua -** $Id: mem.h,v 1.2 1995/01/13 22:11:12 roberto Exp roberto $ +** $Id: mem.h,v 1.3 1996/02/22 20:34:33 roberto Exp roberto $ */ #ifndef mem_h @@ -14,6 +14,7 @@ void luaI_free (void *block); void *luaI_malloc (unsigned long size); void *luaI_realloc (void *oldblock, unsigned long size); +void* luaI_buffer (unsigned long size); #define new(s) ((s *)luaI_malloc(sizeof(s))) #define newvector(n,s) ((s *)luaI_malloc((n)*sizeof(s)))