static void initGlobals()
{
+ int i;
+ struct Context* c;
globals = (struct Globals*)naAlloc(sizeof(struct Globals));
naBZero(globals, sizeof(struct Globals));
globals->sem = naNewSem();
globals->lock = naNewLock();
- int i;
globals->allocCount = 256; // reasonable starting value
for(i=0; i<NUM_NASAL_TYPES; i++)
naGC_init(&(globals->pools[i]), i);
// Initialize a single context
globals->freeContexts = 0;
globals->allContexts = 0;
- struct Context* c = naNewContext();
+ c = naNewContext();
globals->symbols = naNewHash(c);
globals->save = naNewVector(c);
struct Context* naNewContext()
{
int dummy;
+ struct Context* c;
if(globals == 0)
initGlobals();
LOCK();
- struct Context* c = globals->freeContexts;
+ c = globals->freeContexts;
if(c) {
globals->freeContexts = c->nextFree;
c->nextFree = 0;
static naRef setsize(naContext c, naRef me, int argc, naRef* args)
{
+ int sz;
if(argc < 2) return naNil();
- int sz = (int)naNumValue(args[1]).num;
+ sz = (int)naNumValue(args[1]).num;
if(!naIsVector(args[0])) return naNil();
naVec_setsize(args[0], sz);
return args[0];
naRef naNew(struct Context* c, int type)
{
+ naRef result;
if(c->nfree[type] == 0)
c->free[type] = naGC_get(&globals->pools[type],
OBJ_CACHE_SZ, &c->nfree[type]);
- naRef result = naObj(type, c->free[type][--c->nfree[type]]);
+ result = naObj(type, c->free[type][--c->nfree[type]]);
naVec_append(c->temps, result);
return result;
}