Re: memory allocation in GLIB



Hello:

The only time I got segfault freeing a memory block was because it was
already freed. Check for it (just in case).

Hope this helps.

Regards

Beñat

On Mon, 2003-03-10 at 15:10, Jim Parker wrote:
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]