diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-24 14:55:51 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-24 14:55:51 -0300 |
| commit | 9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b (patch) | |
| tree | 18a4b30df4e0518580cd6dc7a370892f5f608021 /lmem.c | |
| parent | 082aded149762ec21a7fa58ef0cc8f9a61038ca7 (diff) | |
| download | lua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.tar.gz lua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.tar.bz2 lua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.zip | |
better instrumentation for internal debugging
Diffstat (limited to 'lmem.c')
| -rw-r--r-- | lmem.c | 19 |
1 files changed, 15 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.c,v 1.8 1999/01/22 17:28:00 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.9 1999/01/22 18:08:57 roberto Exp roberto $ |
| 3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -24,6 +24,8 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | #ifndef DEBUG | ||
| 28 | |||
| 27 | int luaM_growaux (void **block, unsigned long nelems, int size, | 29 | int luaM_growaux (void **block, unsigned long nelems, int size, |
| 28 | char *errormsg, unsigned long limit) { | 30 | char *errormsg, unsigned long limit) { |
| 29 | if (nelems >= limit) | 31 | if (nelems >= limit) |
| @@ -36,9 +38,6 @@ int luaM_growaux (void **block, unsigned long nelems, int size, | |||
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | 40 | ||
| 39 | |||
| 40 | #ifndef DEBUG | ||
| 41 | |||
| 42 | /* | 41 | /* |
| 43 | ** generic allocation routine. | 42 | ** generic allocation routine. |
| 44 | */ | 43 | */ |
| @@ -64,6 +63,18 @@ void *luaM_realloc (void *block, unsigned long size) { | |||
| 64 | #include <string.h> | 63 | #include <string.h> |
| 65 | 64 | ||
| 66 | 65 | ||
| 66 | int luaM_growaux (void **block, unsigned long nelems, int size, | ||
| 67 | char *errormsg, unsigned long limit) { | ||
| 68 | if (nelems >= limit) | ||
| 69 | lua_error(errormsg); | ||
| 70 | nelems = nelems+1; | ||
| 71 | if (nelems > limit) | ||
| 72 | nelems = limit; | ||
| 73 | *block = luaM_realloc(*block, nelems*size); | ||
| 74 | return (int)nelems; | ||
| 75 | } | ||
| 76 | |||
| 77 | |||
| 67 | #define HEADER (sizeof(double)) | 78 | #define HEADER (sizeof(double)) |
| 68 | 79 | ||
| 69 | #define MARK 55 | 80 | #define MARK 55 |
