How the Nasal GC works: Difference between revisions

Jump to navigation Jump to search
m
Line 379: Line 379:
}
}
</syntaxhighlight>
</syntaxhighlight>
= freeelem() =
Frees individual elements and adds freed pointers to the globals free list, implemented in gc.c: https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line137
<syntaxhighlight lang="C">
static void freeelem(struct naPool* p, struct naObj* o)
{
    // Clean up any intrinsic storage the object might have...
    switch(p->type) {
    case T_STR:  naStr_gcclean  ((struct naStr*)  o); break;
    case T_VEC:  naVec_gcclean  ((struct naVec*)  o); break;
    case T_HASH:  naiGCHashClean ((struct naHash*) o); break;
    case T_CODE:  naCode_gcclean ((struct naCode*) o); break;
    case T_GHOST: naGhost_gcclean((struct naGhost*)o); break;
    }
    p->free[p->nfree++] = o;  // ...and add it to the free list
}
</syntaxhighlight>
= Type destructors =
Will be called by freelem(), implemented for all native Nasal types:
* strings (T_STR):  naStr_gcclean [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/string.c#line113]
* vectors (T_VEC):  naVec_gcclean [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/vector.c#line22]
* hashes (T_HASH):  naiGCHashClean [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/hash.c#line221]
* code  (T_CODE):  naCode_gcclean [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line126]
* ghosts (T_GHOST): naGhost_gcclean [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line131]
    }


= Contexts =
= Contexts =

Navigation menu