memory allocation in GLIB



G'Day !

I have a problem (SEGFAULT) when freeing a vector allocated using routines in GLIB (version 1.2.10).

I declare my variable as:
        gfloat *vector;

I then allocate memory as:
        vector = g_malloc ( (some_int)*sizeof(gfloat) );

This allows me to access the memory using:
        for (i=0; i<(some_int); i++)  vector[i] = some_float;

then when exiting the function, I free the memory using:
        g_free( vector );

This statement causes a SEGFAULT. Can anyone suggest what I am doing wrong.

TIA

cheers,
Jim Parker


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