GTK+ 2.0 Tutorial
<<< Previous | GLib | Next >>>

# Memory Management

    gpointer g_malloc( gulong size );

This is a replacement for malloc(). You do not need to check the return value as it is done for you in this function. If the memory allocation fails for whatever reasons, your applications will be terminated.

    gpointer g_malloc0( gulong size );

Same as above, but zeroes the memory before returning a pointer to it.

    gpointer g_realloc( gpointer mem,
                        gulong   size );

Relocates "size" bytes of memory starting at "mem". Obviously, the memory should have been previously allocated.

    void g_free( gpointer mem );

Frees memory. Easy one. If `mem` is NULL it simply returns.

    void g_mem_profile( void );

Dumps a profile of used memory, but requires that you add `#define MEM_PROFILE` to the top of glib/gmem.c and re-make and make install.

    void g_mem_check( gpointer mem );

Checks that a memory location is valid. Requires you add `#define MEM_CHECK` to the top of gmem.c and re-make and make install.

<<< Previous | Home | Next >>>
Singly Linked Lists | Up | Timers