better instrumentation for internal debugging

This commit is contained in:
Roberto Ierusalimschy
1999-02-24 14:55:51 -03:00
parent 082aded149
commit 9d7bae0b6a
4 changed files with 29 additions and 8 deletions

19
lmem.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lmem.c,v 1.8 1999/01/22 17:28:00 roberto Exp roberto $
** $Id: lmem.c,v 1.9 1999/01/22 18:08:57 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@@ -24,6 +24,8 @@
#ifndef DEBUG
int luaM_growaux (void **block, unsigned long nelems, int size,
char *errormsg, unsigned long limit) {
if (nelems >= limit)
@@ -36,9 +38,6 @@ int luaM_growaux (void **block, unsigned long nelems, int size,
}
#ifndef DEBUG
/*
** generic allocation routine.
*/
@@ -64,6 +63,18 @@ void *luaM_realloc (void *block, unsigned long size) {
#include <string.h>
int luaM_growaux (void **block, unsigned long nelems, int size,
char *errormsg, unsigned long limit) {
if (nelems >= limit)
lua_error(errormsg);
nelems = nelems+1;
if (nelems > limit)
nelems = limit;
*block = luaM_realloc(*block, nelems*size);
return (int)nelems;
}
#define HEADER (sizeof(double))
#define MARK 55