The Battle for Wesnoth  1.15.1+dev
Macros | Functions
lmem.h File Reference
#include <stddef.h>
#include "llimits.h"
#include "lua.h"
Include dependency graph for lmem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define luaM_reallocv(L, b, on, n, e)
 
#define luaM_reallocvchar(L, b, on, n)   cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))
 
#define luaM_freemem(L, b, s)   luaM_realloc_(L, (b), (s), 0)
 
#define luaM_free(L, b)   luaM_realloc_(L, (b), sizeof(*(b)), 0)
 
#define luaM_freearray(L, b, n)   luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
 
#define luaM_malloc(L, s)   luaM_realloc_(L, NULL, 0, (s))
 
#define luaM_new(L, t)   cast(t *, luaM_malloc(L, sizeof(t)))
 
#define luaM_newvector(L, n, t)   cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
 
#define luaM_newobject(L, tag, s)   luaM_realloc_(L, NULL, tag, (s))
 
#define luaM_growvector(L, v, nelems, size, t, limit, e)
 
#define luaM_reallocvector(L, v, oldn, n, t)   ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
 

Functions

LUAI_FUNC l_noret luaM_toobig (lua_State *L)
 
LUAI_FUNC void * luaM_realloc_ (lua_State *L, void *block, size_t oldsize, size_t size)
 
LUAI_FUNC void * luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elem, int limit, const char *what)
 

Macro Definition Documentation

◆ luaM_free

#define luaM_free (   L,
  b 
)    luaM_realloc_(L, (b), sizeof(*(b)), 0)

◆ luaM_freearray

#define luaM_freearray (   L,
  b,
  n 
)    luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)

◆ luaM_freemem

#define luaM_freemem (   L,
  b,
  s 
)    luaM_realloc_(L, (b), (s), 0)

Definition at line 41 of file lmem.h.

Referenced by freeLclosure(), and freeobj().

◆ luaM_growvector

#define luaM_growvector (   L,
  v,
  nelems,
  size,
  t,
  limit,
  e 
)
Value:
if ((nelems)+1 > (size)) \
((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
#define cast(t, exp)
Definition: llimits.h:111
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
LUAI_FUNC void * luaM_growaux_(lua_State *L, void *block, int *size, size_t size_elem, int limit, const char *what)
Definition: lmem.cpp:48
double t
Definition: astarsearch.cpp:64
#define e

Definition at line 52 of file lmem.h.

Referenced by addk(), addprototype(), luaK_code(), new_localvar(), newlabelentry(), newupvalue(), and registerlocalvar().

◆ luaM_malloc

#define luaM_malloc (   L,
  s 
)    luaM_realloc_(L, NULL, 0, (s))

Definition at line 45 of file lmem.h.

◆ luaM_new

#define luaM_new (   L,
  t 
)    cast(t *, luaM_malloc(L, sizeof(t)))

Definition at line 46 of file lmem.h.

Referenced by luaE_extendCI(), luaF_findupval(), and luaF_initupvals().

◆ luaM_newobject

#define luaM_newobject (   L,
  tag,
  s 
)    luaM_realloc_(L, NULL, tag, (s))

Definition at line 50 of file lmem.h.

Referenced by lua_newthread(), and luaC_newobj().

◆ luaM_newvector

#define luaM_newvector (   L,
  n,
  t 
)    cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))

◆ luaM_reallocv

#define luaM_reallocv (   L,
  b,
  on,
  n,
  e 
)
Value:
(((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \
? luaM_toobig(L) : cast_void(0)) , \
luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
#define MAX_SIZET
Definition: llimits.h:39
#define cast(t, exp)
Definition: llimits.h:111
#define b
#define cast_void(i)
Definition: llimits.h:113
LUAI_FUNC void * luaM_realloc_(lua_State *L, void *block, size_t oldsize, size_t size)
Definition: lmem.cpp:77
LUAI_FUNC l_noret luaM_toobig(lua_State *L)
Definition: lmem.cpp:68
#define e
static map_location::DIRECTION n

Definition at line 30 of file lmem.h.

Referenced by luaM_growaux_().

◆ luaM_reallocvchar

#define luaM_reallocvchar (   L,
  b,
  on,
  n 
)    cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))

Definition at line 38 of file lmem.h.

◆ luaM_reallocvector

#define luaM_reallocvector (   L,
  v,
  oldn,
  n,
  t 
)    ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))

Definition at line 56 of file lmem.h.

Referenced by close_func(), luaD_reallocstack(), luaH_resize(), luaS_resize(), and setarrayvector().

Function Documentation

◆ luaM_growaux_()

LUAI_FUNC void* luaM_growaux_ ( lua_State L,
void *  block,
int *  size,
size_t  size_elem,
int  limit,
const char *  what 
)

Definition at line 48 of file lmem.cpp.

References luaG_runerror(), luaM_reallocv, and MINSIZEARRAY.

◆ luaM_realloc_()

LUAI_FUNC void* luaM_realloc_ ( lua_State L,
void *  block,
size_t  oldsize,
size_t  size 
)

◆ luaM_toobig()

LUAI_FUNC l_noret luaM_toobig ( lua_State L)

Definition at line 68 of file lmem.cpp.

References luaG_runerror().

Referenced by luaS_newlstr(), and luaS_newudata().