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] |
On Mon, Apr 19, 1999 at 08:29:43PM -0230, Greg Harvey wrote: >> >forcer <forcer@mindless.com> writes: >> >> f = scm_must_malloc(sizeof(some_struct)); >> >> f->data = scm_must_malloc(size); >> >> >> >> and there won't be enough free memory for the second >> >> scm_must_malloc even after gc, the allocated memory in f is >> >> lost and won't be free'd. Is that true? > >Sorry, I didn't read the first message well (it's been one of those >days... I meant nope in that f will not be free'd, so it should've >been yep ;)). This memory will be lost if this is the case; there's >not all that a generic type of malloc could do about it; the >alternatives are using something like the scm_malloc implementation >(in mallocs.c); scm_malloc_obj - the only scm_malloc* i could find in mallocs.c - does something similar to what i think right, but not entirely. First, it sets up a Scheme object. That's nice since it will be gc'd. But it doesn't call GC to get more free storage. IMHO the best solution to this problem would be to have a char *scm_malloc(size_t len) which does almost the same as scm_must_malloc, except that it, instead of throwing an exceptiong should just return NULL. Hmm.. related to this, why do the guile malloc functions return char* and not void*? for hysterical raisins, e.g. K&R? :] -forcer -- ((email . "forcer@mindless.com") (www . "http://webserver.de/forcer/") (irc . "forcer@#StarWars (IRCnet)") (pgp . "key available on my website"))