mirror of
https://github.com/lua/lua
synced 2024-11-23 21:29:38 +03:00
new function "luaI_buffer".
This commit is contained in:
parent
675e608325
commit
7236df875a
12
luamem.c
12
luamem.c
@ -3,7 +3,7 @@
|
|||||||
** TecCGraf - PUC-Rio
|
** 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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -53,3 +53,13 @@ void *luaI_realloc (void *oldblock, unsigned long size)
|
|||||||
return block;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
3
luamem.h
3
luamem.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** mem.c
|
** mem.c
|
||||||
** memory manager for lua
|
** 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
|
#ifndef mem_h
|
||||||
@ -14,6 +14,7 @@
|
|||||||
void luaI_free (void *block);
|
void luaI_free (void *block);
|
||||||
void *luaI_malloc (unsigned long size);
|
void *luaI_malloc (unsigned long size);
|
||||||
void *luaI_realloc (void *oldblock, 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 new(s) ((s *)luaI_malloc(sizeof(s)))
|
||||||
#define newvector(n,s) ((s *)luaI_malloc((n)*sizeof(s)))
|
#define newvector(n,s) ((s *)luaI_malloc((n)*sizeof(s)))
|
||||||
|
Loading…
Reference in New Issue
Block a user