mirror of
https://github.com/lua/lua
synced 2024-11-22 12:51:30 +03:00
details
This commit is contained in:
parent
18fb3ddb89
commit
0ffc676ce7
26
lmem.c
26
lmem.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmem.c,v 1.35 2000/08/04 19:38:35 roberto Exp roberto $
|
||||
** $Id: lmem.c,v 1.36 2000/08/09 19:16:57 roberto Exp roberto $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -15,15 +15,6 @@
|
||||
#include "lstate.h"
|
||||
|
||||
|
||||
/*
|
||||
** Real ISO (ANSI) systems do not need these tests;
|
||||
** but some systems (Sun OS) are not that ISO...
|
||||
*/
|
||||
#ifdef OLD_ANSI
|
||||
#define realloc(b,s) ((b) == NULL ? malloc(s) : (realloc)(b, s))
|
||||
#define free(b) if (b) (free)(b)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -38,11 +29,8 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef realloc
|
||||
#undef malloc
|
||||
#undef free
|
||||
#define realloc(b, s) debug_realloc(b, s)
|
||||
#define malloc(b) debug_realloc(NULL, 0)
|
||||
#define malloc(b) debug_realloc(NULL, b)
|
||||
#define free(b) debug_realloc(b, 0)
|
||||
|
||||
|
||||
@ -119,6 +107,16 @@ static void *debug_realloc (void *block, size_t size) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Real ISO (ANSI) systems do not need these tests;
|
||||
** but some systems (Sun OS) are not that ISO...
|
||||
*/
|
||||
#ifdef OLD_ANSI
|
||||
#define realloc(b,s) ((b) == NULL ? malloc(s) : (realloc)(b, s))
|
||||
#define free(b) if (b) (free)(b)
|
||||
#endif
|
||||
|
||||
|
||||
void *luaM_growaux (lua_State *L, void *block, size_t nelems,
|
||||
int inc, size_t size, const char *errormsg, size_t limit) {
|
||||
size_t newn = nelems+inc;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 1.52 2000/10/05 12:14:08 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 1.53 2000/10/09 13:47:32 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -87,16 +87,14 @@ void luaO_verror (lua_State *L, const char *fmt, ...) {
|
||||
}
|
||||
|
||||
|
||||
#define EXTRALEN sizeof(" string \"s...\" ")
|
||||
|
||||
void luaO_chunkid (char *out, const char *source, int bufflen) {
|
||||
if (*source == '=')
|
||||
sprintf(out, "%.*s", bufflen, source+1); /* remove first char */
|
||||
sprintf(out, "%.*s", bufflen-1, source+1); /* remove first char */
|
||||
else {
|
||||
bufflen -= EXTRALEN;
|
||||
if (*source == '@') {
|
||||
int l;
|
||||
source++; /* skip the `@' */
|
||||
bufflen -= sizeof("file `...%s'");
|
||||
l = strlen(source);
|
||||
if (l>bufflen) {
|
||||
source += (l-bufflen); /* get last part of file name */
|
||||
@ -107,6 +105,7 @@ void luaO_chunkid (char *out, const char *source, int bufflen) {
|
||||
}
|
||||
else {
|
||||
int len = strcspn(source, "\n"); /* stop at first newline */
|
||||
bufflen -= sizeof("string \"%.*s...\"");
|
||||
if (len > bufflen) len = bufflen;
|
||||
if (source[len] != '\0') /* must truncate? */
|
||||
sprintf(out, "string \"%.*s...\"", len, source);
|
||||
|
Loading…
Reference in New Issue
Block a user