[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] scm_dynwinds etc. [was:] Midi shortcuts

From: R. Mattes
Subject: Re: [Denemo-devel] scm_dynwinds etc. [was:] Midi shortcuts
Date: Wed, 11 May 2011 17:59:18 +0200

On Wed, 11 May 2011 16:00:57 +0100, Richard Shann wrote
> In practice this just means removing all the scm_dynwind stuff that you
> did, as we don't do any non-local jumps from scheme. 

Here I disagree - you cannot predict what user-provided scheme code
might do. And scheme code might always throw an uncought
exception. This would lead to leaking memory.

> Instead free 
> any C strings created with scm_to_locale_string() using free() (not 
> g_free()).

Yes, even so g_free might be just a call to free, on some platforms memory
must be freed by the same allocator library as the one that created it.
>  More importantly the scm_take_from... need to revert to scm_from... 
> in all cases. In the cases where the string being passed is freshly 
> allocated (ie g_malloc'd) then call g_free() on it having created 
> the scm_from... SCM structure.

And dont' forget to register it with the dynamic context! ;-)
> We can't exploit scm_take_from... (as 
> I previously suggested) because it calls free() and glib  is using 
> its own memory allocator (so g_free() doesn't call free()). (So, 
> another wild goose chase started by me I'm afraid :(

Ah, good to know. Anyway, looking at scm_take_from... in Guile 2 there will
be no benefit performance-wise anyway. 
> It is only not crashing at the moment, because it seems scheme is not
> collecting its garbage...

Have you tested with manual gc?

 Cheers, RalfD

reply via email to

[Prev in Thread] Current Thread [Next in Thread]