This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
dirk@ida.ing.tu-bs.de writes: > Hello! > > Am I right in assuming that SCM objects are only protected from gc as long > as they are on the stack and not if they are on the heap? > If SCM values are on the stack, they are autiomatically protected against gc. If they are on the heap, they must be protected explictly, such as with scm_protect_object()/scm_unprotect_object(). One problem with scm_[un]protect_object for your application (and others) is that > example (just sketched): > > SCM* p = new SCM[100]; /* C++ style, for C use malloc */ > for (unsigned int i = 0; i < 100; ++i) > p[i] = gh_cons(SCM_BOOL_T, SCM_BOOL_T); > > If I am right, later accesses to p are not guaranteed to work with current > guile, since the SCM objects referencing the pairs will not be detected > during gc. > Correct, unless you protect each of the slots in the array explicitly. This is undoubtedly quite a pain in this case. Maybe Guile could use a scm_protect_range(void *addr, size_t size) which would conservatively protect an address range against GC until that range is unprotected (I guess this would require a unique handle return value to be passed to scm_unprotect_range). - Maciej