[gcompris-devel] memory management problem

pgeorges pascal.georges1 at free.fr
Sat Dec 22 01:59:58 UTC 2001


In algebra_guesscount.c, I load pixmap files in start_board with

for (i=0; i<NUM_VALUES; i++) {
	str = g_strdup_printf("%s/%d.png",
gcomprisBoard->boarddir,num_values[i]);
	num_pixmap[i] = gcompris_load_pixmap(str);
	g_free(str);
}
for (i=0; i<5; i++) {
	str = g_strdup_printf("%s/%c.png",
gcomprisBoard->boarddir,oper_values[i]);
	oper_pixmap[i] = gcompris_load_pixmap(str);
	 g_free(str);
}

Then in destroy_board, called from end_board :

/* ==================================== */
static void end_board () {
  if(gcomprisBoard!=NULL) {
      pause_board(TRUE);
      gcompris_score_end();
      destroy_board();
      algebra_guesscount_destroy_all_items();
    }
}

I do the following to clean the pixmap allocated memory (or I think so)
: 

static void destroy_board() {
int i;
for (i=0; i<NUM_VALUES; i++)
  gdk_pixbuf_unref(num_pixmap[i]);
for (i=0; i<5; i++)
  gdk_pixbuf_unref(oper_pixmap[i]);
}



But this seems to make a segfault when playing several times with the
board. So is the 'gdk_pixbuf_unref' call mandatory to avoid memory
leakage ?

Pascal





More information about the Gcompris-devel mailing list