]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/gc.c
cppbind.Ghost: clean up a bit
[simgear.git] / simgear / nasal / gc.c
index e9d9b7b8ba60587f9618eca6e25fab55a3a8a5f5..a965aa79c523e3f881a9b4d3e2ad1d53b69e4239 100644 (file)
@@ -54,6 +54,7 @@ static void garbageCollect()
     }
 
     mark(globals->save);
+    mark(globals->save_hash);
     mark(globals->symbols);
     mark(globals->meRef);
     mark(globals->argRef);
@@ -118,6 +119,15 @@ static void bottleneck()
     }
 }
 
+void naGC()
+{
+    LOCK();
+    globals->needGC = 1;
+    bottleneck();
+    UNLOCK();
+    naCheckBottleneck();
+}
+
 void naCheckBottleneck()
 {
     if(globals->bottleneck) { LOCK(); bottleneck(); UNLOCK(); }
@@ -128,6 +138,12 @@ static void naCode_gcclean(struct naCode* o)
     naFree(o->constants);  o->constants = 0;
 }
 
+static void naCCode_gcclean(struct naCCode* c)
+{
+    if(c->fptru && c->user_data && c->destroy) c->destroy(c->user_data);
+    c->user_data = 0;
+}
+
 static void naGhost_gcclean(struct naGhost* g)
 {
     if(g->ptr && g->gtype->destroy) g->gtype->destroy(g->ptr);
@@ -142,6 +158,7 @@ static void freeelem(struct naPool* p, struct naObj* o)
     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_CCODE: naCCode_gcclean((struct naCCode*)o); break;
     case T_GHOST: naGhost_gcclean((struct naGhost*)o); break;
     }
     p->free[p->nfree++] = o;  // ...and add it to the free list