summaryrefslogtreecommitdiff
path: root/libguile/gc.c
diff options
context:
space:
mode:
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-12-28 16:49:09 +0000
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-12-28 16:49:09 +0000
commit5d2b97cd077bb3d63e47729c800edc349e583f8e (patch)
tree02059c2070dc771ef6ea478c59edeb46506b83c1 /libguile/gc.c
parentfcba9b58c677407263282a4028f55c33151d2ca5 (diff)
downloadguile-5d2b97cd077bb3d63e47729c800edc349e583f8e.tar.gz
* Fixed the changelog entry regarding re-introduction of struct member
properties (I continuously talked of member 'documentation' instead) * Replace calls to scm_remember with calls to scm_remember_upto_here_1.
Diffstat (limited to 'libguile/gc.c')
-rw-r--r--libguile/gc.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libguile/gc.c b/libguile/gc.c
index b1095d135..d6767651d 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -2316,12 +2316,59 @@ SCM_DEFINE (scm_unhash_name, "unhash-name", 1, 0, 0,
*/
+/*
+ * If within a function you need to protect one or more scheme objects from
+ * garbage collection, pass them as parameters to one of the
+ * scm_remember_upto_here* functions below. These functions don't do
+ * anything, but since the compiler does not know that they are actually
+ * no-ops, it will generate code that calls these functions with the given
+ * parameters. Therefore, you can be sure that the compiler will keep those
+ * scheme values alive (on the stack or in a register) up to the point where
+ * scm_remember_upto_here* is called. In other words, place the call to
+ * scm_remember_upt_here* _behind_ the last code in your function, that
+ * depends on the scheme object to exist.
+ *
+ * Example: We want to make sure, that the string object str does not get
+ * garbage collected during the execution of 'some_function', because
+ * otherwise the characters belonging to str would be freed and
+ * 'some_function' might access freed memory. To make sure that the compiler
+ * keeps str alive on the stack or in a register such that it is visible to
+ * the conservative gc we add the call to scm_remember_upto_here_1 _after_ the
+ * call to 'some_function'. Note that this would not be necessary if str was
+ * used anyway after the call to 'some_function'.
+ * char *chars = SCM_STRING_CHARS (str);
+ * some_function (chars);
+ * scm_remember_upto_here_1 (str); // str will be alive up to this point.
+ */
+
+void
+scm_remember_upto_here_1 (SCM obj)
+{
+ /* Empty. Protects a single object from garbage collection. */
+}
+
+void
+scm_remember_upto_here_2 (SCM obj1, SCM obj2)
+{
+ /* Empty. Protects two objects from garbage collection. */
+}
+
+void
+scm_remember_upto_here (SCM obj, ...)
+{
+ /* Empty. Protects any number of objects from garbage collection. */
+}
+
+
+#if (SCM_DEBUG_DEPRECATED == 0)
+
void
scm_remember (SCM *ptr)
{
/* empty */
}
+#endif /* SCM_DEBUG_DEPRECATED == 0 */
/*
These crazy functions prevent garbage collection