diff options
Diffstat (limited to '')
| -rw-r--r-- | luamem.c | 12 | ||||
| -rw-r--r-- | luamem.h | 3 |
2 files changed, 13 insertions, 2 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_mem = "$Id: mem.c,v 1.7 1996/02/04 16:59:12 roberto Exp roberto $"; | 6 | char *rcs_mem = "$Id: mem.c,v 1.8 1996/02/22 20:34:33 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -53,3 +53,13 @@ void *luaI_realloc (void *oldblock, unsigned long size) | |||
| 53 | return block; | 53 | return block; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | |||
| 57 | void* luaI_buffer (unsigned long size) | ||
| 58 | { | ||
| 59 | static unsigned long buffsize = 0; | ||
| 60 | static char* buffer = NULL; | ||
| 61 | if (size > buffsize) | ||
| 62 | buffer = luaI_realloc(buffer, buffsize=size); | ||
| 63 | return buffer; | ||
| 64 | } | ||
| 65 | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** mem.c | 2 | ** mem.c |
| 3 | ** memory manager for lua | 3 | ** memory manager for lua |
| 4 | ** $Id: mem.h,v 1.2 1995/01/13 22:11:12 roberto Exp roberto $ | 4 | ** $Id: mem.h,v 1.3 1996/02/22 20:34:33 roberto Exp roberto $ |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifndef mem_h | 7 | #ifndef mem_h |
| @@ -14,6 +14,7 @@ | |||
| 14 | void luaI_free (void *block); | 14 | void luaI_free (void *block); |
| 15 | void *luaI_malloc (unsigned long size); | 15 | void *luaI_malloc (unsigned long size); |
| 16 | void *luaI_realloc (void *oldblock, unsigned long size); | 16 | void *luaI_realloc (void *oldblock, unsigned long size); |
| 17 | void* luaI_buffer (unsigned long size); | ||
| 17 | 18 | ||
| 18 | #define new(s) ((s *)luaI_malloc(sizeof(s))) | 19 | #define new(s) ((s *)luaI_malloc(sizeof(s))) |
| 19 | #define newvector(n,s) ((s *)luaI_malloc((n)*sizeof(s))) | 20 | #define newvector(n,s) ((s *)luaI_malloc((n)*sizeof(s))) |
