cat GString.c
#include <mcheck.h>
#include <glib.h>
#include <stdio.h>
int main(int argc, char **argv)
{mtrace();
fprintf(stderr, "GLib %u.%u.%u\n", glib_major_version, glib_minor_version, glib_micro_version);
fprintf(stderr, "GCC %ld\n", __STDC_VERSION__);
if (argc > 1)
{fprintf(stderr, "Allocate and free GString\n");
GString *p = g_string_new("");
g_string_free(p, 1);
}
else
{fprintf(stderr, "Do nothing\n");
}
return 0;
}
gcc -g -rdynamic -O0 -Wall -fstack-protector-strong -I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o "GString" GString.c -lglib-2.0
MALLOC_TRACE='zzz.txt' /home/phil/c/z/glib/GString
mtrace zzz.txt
- GLib 2.56.4
- GCC 201710
- Do nothing
- No memory leaks.
gcc -g -rdynamic -O0 -Wall -fstack-protector-strong -I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o "GString" GString.c -lglib-2.0
MALLOC_TRACE='zzz.txt' /home/phil/c/z/glib/GString 1
mtrace zzz.txt
- GLib 2.56.4
- GCC 201710
- Allocate and free GString
Memory not freed:
-----------------
Address Size Caller
0x00005653a3fe1600 0x1f0 at 0x7f5618ad60e7
0x00005653a3fe1a00 0x1f0 at 0x7f5618ad60e7
0x00005653a3fe1e00 0x1f0 at 0x7f5618ad60e7
0x00005653a3fe2200 0x1f0 at 0x7f5618ad60e7