guile-user
[Top][All Lists]
Advanced

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

Re: Guile 1.8 Garbage Collection Question


From: rixed
Subject: Re: Guile 1.8 Garbage Collection Question
Date: Wed, 26 Oct 2011 18:30:18 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Now that I've replied to your last message, I think I've spotted the bug:

-[ Tue, Oct 25, 2011 at 08:34:23PM +0000, Whitlock, Bradley D ]----
> {
>   // Storage for temporary string
>   char* s = NULL;
>   scm_dynwind_begin (0);
>   scm_dynwind_unwind_handler (free, s, SCM_F_WIND_EXPLICITLY);
> 
>   s = scm_to_locale_string (scm_val);
> 
>   fstWriterEmitValueChange(SCM_TO_CTX (scm_ctx),
>                                                    SCM_TO_FSTHANDLE 
> (scm_fsthandle),
>                                                    s_buf);
> 
>   scm_dynwind_end();
> 
>   return SCM_UNSPECIFIED;
> }

Here you are calling scm_dynwind_unwind_handler with NULL (the current
value of s), which is useless. It will call free(NULL) to free s, which
is not very usefull.
You must move this call after the initialization of s (and, as
suggested, you'd better use scm_dynwind_free, which is equivalent to
scm_dynwind_unwind_handler(free)).




reply via email to

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