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]

Re: scm_must_malloc and memory leaking?


forcer <forcer@mindless.com> writes:

> 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.

That could be done; the only problem is picking good names for the
different flavours (scm_must_* sucks in any case; so a better name for
that, and names for the variants to distinguish what they're doing; or
maybe just scm_*alloc(size, type), where type is a collection of the
flags SCM_OBJ, SCM_NONOBJ, SCM_NOERROR (nonobj to prevent it from
being added to scm_mallocated, since the gc can never free the
object; noerror prevents a memory error from being thrown)).

> Hmm.. related to this, why do the guile malloc functions return
> char* and not void*? for hysterical raisins, e.g. K&R? :]

Bingo (actually, I changed them to void in thing... the warnings were
getting on my nerves ;). 


-- 
Greg