diff options
-rw-r--r-- | byterun/memory.h | 8 | ||||
-rw-r--r-- | byterun/roots.c | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/byterun/memory.h b/byterun/memory.h index 252873e57..95f0a6c99 100644 --- a/byterun/memory.h +++ b/byterun/memory.h @@ -97,10 +97,16 @@ extern value *local_roots; #define Pop_roots() {local_roots = (value *) local_roots [1]; } /* [register_global_root] registers a global C variable as a memory root - for the duration of the program. */ + for the duration of the program, or until [remove_global_root] is + called. */ void register_global_root P((value *)); +/* [remove_global_root] removes a memory root registered on a global C + variable with [register_global_root]. */ + +void remove_global_root P((value *)); + #endif /* _memory_ */ diff --git a/byterun/roots.c b/byterun/roots.c index a9dfd2065..055b7c763 100644 --- a/byterun/roots.c +++ b/byterun/roots.c @@ -44,6 +44,22 @@ void register_global_root(r) global_roots = gr; } +/* Un-register a global C root */ + +void remove_global_root(r) + value * r; +{ + struct global_root ** gp, * gr; + for (gp = &global_roots; *gp != NULL; gp = &(*gp)->next) { + gr = *gp; + if (gr->root == r) { + *gp = gr->next; + stat_free((char *) gr); + return; + } + } +} + /* Call [oldify] on all roots except [global_data] */ void oldify_local_roots () |