[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
smob GC question
From: |
Eric Enderton |
Subject: |
smob GC question |
Date: |
Tue, 3 Oct 2000 22:18:08 -0700 |
i'm reading data-rep.info, particularly the section "A Common
Mistake In Allocating Smobs". (it's great -- thank you!)
i have one question/concern, right at the end:
A correct implementation might say, instead:
image->name = SCM_BOOL_F;
image->update_func = SCM_BOOL_F;
SCM_NEWCELL (image_smob);
SCM_SETCDR (image_smob, image);
SCM_SETCAR (image_smob, image_tag);
image->name = scm_string_copy (name);
image->update_func = scm_make_gsubr (...);
return image_smob;
Now, by the time we allocate the new string and function objects,
`image_smob' points to `image'. If the garbage collector scans the
stack, it will find a reference to `image_smob' and traverse `image',
so any objects `image' points to will be preserved.
if GC runs during, say, the scm_make_gsubr(), where does it
find a reference to image_smob? no cells point to it yet.
and if it doesn't get marked, aren't we in trouble?
thanks for any enlightenment,
-E
p.s. i sure hope you only get one copy of this ...
- smob GC question,
Eric Enderton <=