A few days ago, a friend mentioned that valgrind[1] detects memory leaks
in a piece of software I've written. So I installed valgrind (version
2.0.0) to check it out and... yup, I get the same results.

[1] http://valgrind.kde.org/

The program below demonstrates the problem - valgrind notes "4 allocs"
and "0 frees". (Change the printf to a g_print for extra fun.)


/* foo.c - testing valgrind and glib-2.0
 *
 * gcc -Wall `pkg-config --cflags glib-2.0` \
 *           `pkg-config --libs glib-2.0` foo.c -o foo
 */

#include <stdio.h>
#include <glib.h>

int
main (int argc, char *argv[])
{
    GList *l = NULL;

    l = g_list_append (l, GINT_TO_POINTER(42));
    printf ("%d\n", GPOINTER_TO_INT(l->data));
    g_list_free (l);

    return 0;
}


So, am I misunderstanding glib-2.0?
Or is it just that valgrind needs a suppression file for glib-2.0?

My glib-2.0 version:

  $ pkg-config --modversion glib-2.0
  2.4.1

Thanks for any hints,

Tim
-- 
Timothy Musson  -  [EMAIL PROTECTED]
http://homepages.ihug.co.nz/~trmusson/

Reply via email to