Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lmem.c File Reference
#include <stddef.h>
#include "lua.h"
#include "ldebug.h"
#include "ldo.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"

Go to the source code of this file.

Macros

#define lmem_c
 
#define LUA_CORE
 
#define MINSIZEARRAY   4
 

Functions

void * luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, int limit, const char *errormsg)
 
void * luaM_toobig (lua_State *L)
 
void * luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize)
 

Macro Definition Documentation

◆ lmem_c

#define lmem_c

Definition at line 10 of file lua-5.1.5/src/lmem.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 11 of file lua-5.1.5/src/lmem.c.

◆ MINSIZEARRAY

#define MINSIZEARRAY   4

Definition at line 43 of file lua-5.1.5/src/lmem.c.

Referenced by luaM_growaux_().

Function Documentation

◆ luaM_growaux_()

void * luaM_growaux_ ( lua_State * L,
void * block,
int * size,
size_t size_elems,
int limit,
const char * errormsg )

Definition at line 46 of file lua-5.1.5/src/lmem.c.

47 {
48 void *newblock;
49 int newsize;
50 if (*size >= limit/2) { /* cannot double it? */
51 if (*size >= limit) /* cannot grow even a little? */
52 luaG_runerror(L, errormsg);
53 newsize = limit; /* still have at least one free place */
54 }
55 else {
56 newsize = (*size)*2;
57 if (newsize < MINSIZEARRAY)
58 newsize = MINSIZEARRAY; /* minimum size */
59 }
60 newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
61 *size = newsize; /* update only when everything else is OK */
62 return newblock;
63}
void luaG_runerror(lua_State *L, const char *fmt,...)
#define MINSIZEARRAY
#define luaM_reallocv(L, b, on, n, e)
static void block(LexState *ls)

References block(), luaG_runerror(), luaM_reallocv, and MINSIZEARRAY.

◆ luaM_realloc_()

void * luaM_realloc_ ( lua_State * L,
void * block,
size_t osize,
size_t nsize )

Definition at line 76 of file lua-5.1.5/src/lmem.c.

76 {
77 global_State *g = G(L);
78 lua_assert((osize == 0) == (block == NULL));
79 block = (*g->frealloc)(g->ud, block, osize, nsize);
80 if (block == NULL && nsize > 0)
82 lua_assert((nsize == 0) == (block == NULL));
83 g->totalbytes = (g->totalbytes - osize) + nsize;
84 return block;
85}
#define NULL
Definition gmacros.h:924
void luaD_throw(lua_State *L, int errcode)
#define lua_assert(c)
#define G(L)
#define LUA_ERRMEM

References block(), global_State::frealloc, G, lua_assert, LUA_ERRMEM, luaD_throw(), NULL, global_State::totalbytes, and global_State::ud.

◆ luaM_toobig()

void * luaM_toobig ( lua_State * L)

Definition at line 66 of file lua-5.1.5/src/lmem.c.

66 {
67 luaG_runerror(L, "memory allocation error: block too big");
68 return NULL; /* to avoid warnings */
69}

References luaG_runerror(), and NULL.

Referenced by luaS_newlstr(), luaS_newudata(), luaS_newudata(), luaS_newudata(), and newlstr().