Re: possible g_hash_table mem leak?



On Tue, 4 Jan 2005 16:04:23 +0000, Eli Yukelzon <reflog gmail com> wrote:
> Hi there.
> I've stumbled uppon some weird behavior of g_hash_table, maybe some
> one can tell me if I wrong with this, or is this a real memory leak.
> Here's a little c prog that demonstrates the problem:
> ====================
> #include <glib.h>
> void main(){
>         GHashTable * h= g_hash_table_new_full  (
> g_str_hash,g_str_equal, g_free,g_free);
>         char *a,*b,*c,*d,*e,*f;
>         asprintf(&a,"a");
>         asprintf(&b,"b");
>         g_hash_table_insert(h,a,b);
>         g_hash_table_destroy (h);
> }
> ====================

Your problem is probably that you are combining asprintf() with g_free(),
using g_strdup_printf should give you better results.

Cheers,
                                              -Tristan



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