From 0bbdddc86b1353fec36ae886b4142986f3c4713f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 17 Dec 2009 13:46:44 -0200 Subject: allocator function receives the tag of object being allocated in 'osize' when 'ptr' is NULL. --- lgc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index 286b2213..7a3df48a 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.64 2009/12/11 19:14:59 roberto Exp roberto $ +** $Id: lgc.c,v 2.65 2009/12/11 21:31:14 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -116,12 +116,20 @@ void luaC_barrierback (lua_State *L, Table *t) { } -void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { +/* +** create a new collectable object and link it to '*list' +*/ +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, + int offset) { global_State *g = G(L); + GCObject *o = obj2gco(cast(char *, luaM_newobject(L, tt, sz)) + offset); + if (list == NULL) + list = &g->rootgc; /* standard list for collectable objects */ gch(o)->marked = luaC_white(g); gch(o)->tt = tt; - gch(o)->next = g->rootgc; - g->rootgc = o; + gch(o)->next = *list; + *list = o; + return o; } -- cgit v1.2.3-55-g6feb