aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-17 13:46:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-17 13:46:44 -0200
commit0bbdddc86b1353fec36ae886b4142986f3c4713f (patch)
tree9eb933c8123911f9477e8b8b55344035c8077c01 /lgc.c
parentb3b8dfaaea2dba7e7b4b898a5f767a80f36319f1 (diff)
downloadlua-0bbdddc86b1353fec36ae886b4142986f3c4713f.tar.gz
lua-0bbdddc86b1353fec36ae886b4142986f3c4713f.tar.bz2
lua-0bbdddc86b1353fec36ae886b4142986f3c4713f.zip
allocator function receives the tag of object being allocated in 'osize'
when 'ptr' is NULL.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lgc.c b/lgc.c
index 286b2213..7a3df48a 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.64 2009/12/11 19:14:59 roberto Exp roberto $ 2** $Id: lgc.c,v 2.65 2009/12/11 21:31:14 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -116,12 +116,20 @@ void luaC_barrierback (lua_State *L, Table *t) {
116} 116}
117 117
118 118
119void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { 119/*
120** create a new collectable object and link it to '*list'
121*/
122GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list,
123 int offset) {
120 global_State *g = G(L); 124 global_State *g = G(L);
125 GCObject *o = obj2gco(cast(char *, luaM_newobject(L, tt, sz)) + offset);
126 if (list == NULL)
127 list = &g->rootgc; /* standard list for collectable objects */
121 gch(o)->marked = luaC_white(g); 128 gch(o)->marked = luaC_white(g);
122 gch(o)->tt = tt; 129 gch(o)->tt = tt;
123 gch(o)->next = g->rootgc; 130 gch(o)->next = *list;
124 g->rootgc = o; 131 *list = o;
132 return o;
125} 133}
126 134
127 135