Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-10-16 21:59:37 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-10-16 21:59:37 (GMT)
commit921af30d081af8274fbe57dd5eeb5de2531376f5 (patch)
treee6fdeaa66757cb42981e5d26a1afe407ec24cfb4
parent8d5eabeb6409c568e6143cc0d6bab1bb7733ec4a (diff)
- Applied patch from Miguel DE IZARRA that removes memory leaks
-rw-r--r--ChangeLog22
-rw-r--r--Makefile.mingw52
-rw-r--r--config.h.mingw2
-rw-r--r--configure.in2
-rw-r--r--src/boards/algebra.c45
-rw-r--r--src/boards/canal_lock.c1
-rw-r--r--src/boards/hanoi.c12
-rw-r--r--src/boards/shapegame.c1
-rw-r--r--src/gcompris/anim.c3
-rw-r--r--src/gcompris/gameutil.c3
-rw-r--r--src/gcompris/gc_core.h1
-rw-r--r--src/gcompris/gcompris.c1
-rw-r--r--src/gcompris/images_selector.c10
-rw-r--r--src/gcompris/menu.c67
-rw-r--r--src/gcompris/soundutil.c1
15 files changed, 142 insertions, 81 deletions
diff --git a/ChangeLog b/ChangeLog
index ef04e44..75032b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2006-10-16 Bruno coudoin <bruno.coudoin@free.fr>
+ - Applied patch from Miguel DE IZARRA that removes memory leaks
+
+ * Makefile.mingw:
+ * config.h.mingw:
+ * configure.in:
+ * src/boards/algebra.c: (algebra_destroy_all_items),
+ (display_operand):
+ * src/boards/canal_lock.c: (canal_lock_create_item):
+ * src/boards/hanoi.c: (start_board), (hanoi_create_item):
+ * src/boards/shapegame.c: (add_xml_shape_to_data):
+ * src/gcompris/anim.c: (gc_anim_load), (gc_anim_free):
+ * src/gcompris/gameutil.c: (reactivate_newline):
+ * src/gcompris/gc_core.h:
+ * src/gcompris/gcompris.c: (cleanup):
+ * src/gcompris/images_selector.c: (read_dataset_directory):
+ * src/gcompris/menu.c: (_add_xml_to_data), (gc_menu_load_dir),
+ (gc_menu_load), (gc_menu_board_free), (gc_menu_destroy):
+ * src/gcompris/soundutil.c: (gc_sound_alphabet):
+
+2006-10-16 Bruno coudoin <bruno.coudoin@free.fr>
+
- Some fixed to compile and run 8.1 on windows.
* Makefile.mingw:
@@ -39,6 +60,7 @@
2006-10-15 Bruno coudoin <bruno.coudoin@free.fr>
- Updated Indian Marathi voices by Anand Kulkarni
+ Credit goes to 'Sarvangin Vikas Sanstha'
* boards/sounds/mr/alphabet/10.ogg:
* boards/sounds/mr/alphabet/11.ogg:
diff --git a/Makefile.mingw b/Makefile.mingw
index 77c938c..a148347 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -4,7 +4,7 @@
# Description: Top Makefile for win32 (mingw) port of GCompris
#
-VERSION = "8.1"
+VERSION = "8.2"
pkgdatadir = gcompris
@@ -18,52 +18,48 @@ LIBXML2_TOP := /libxml2
SDL_TOP := /sdl
CANVAS_TOP := /gnomecanvas
GNUCHESS_TOP := /gnuchess
-GNUCAP_TOP := /gnucap
MAKENSIS := "/c/Program Files/NSIS/makensis.exe"
# These will be copied in the win32-install-dir ready to be packaged.
-NEEDED_DLLS = $(CANVAS_TOP)/bin/libgnomecanvas-2-0.dll \
- $(GNUCAP_TOP)/src/MSW/gnucap.exe \
- $(GNUCHESS_TOP)/bin/gnuchess.exe \
+NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \
$(GNUCHESS_TOP)/bin/libreadline.dll \
- $(GNUWIN32_TOP)/bin/libiconv-2.dll \
- $(GNUWIN32_TOP)/bin/libintl-2.dll \
+ $(GTK_TOP)/bin/gspawn-win32-helper.exe \
+ $(GNUCHESS_TOP)/bin/gnuchess.exe \
$(GNUWIN32_TOP)/bin/popt1.dll \
+ $(GNUWIN32_TOP)/bin/libintl-2.dll \
+ $(GNUWIN32_TOP)/bin/libiconv-2.dll \
+ $(CANVAS_TOP)/bin/libgnomecanvas-2-0.dll \
+ $(SDL_TOP)/bin/SDL.dll \
+ $(SDL_TOP)/bin/SDL_mixer.dll \
+ $(LIBXML2_TOP)/bin/libxml2.dll \
$(GTK_TOP)/bin/freetype6.dll \
- $(GTK_TOP)/bin/freetype6.dll \
- $(GTK_TOP)/bin/gspawn-win32-helper.exe \
- $(GTK_TOP)/bin/iconv.dll \
$(GTK_TOP)/bin/intl.dll \
- $(GTK_TOP)/bin/intl.dll \
- $(GTK_TOP)/bin/jpeg62.dll
$(GTK_TOP)/bin/libart_lgpl_2-2.dll \
- $(GTK_TOP)/bin/libatk-1.0-0.dll \
- $(GTK_TOP)/bin/libcairo-2.dll \
- $(GTK_TOP)/bin/libfontconfig-1.dll \
+ $(GTK_TOP)/bin/freetype6.dll \
+ $(GTK_TOP)/bin/libart_lgpl_2-2.dll \
$(GTK_TOP)/bin/libgdk-win32-2.0-0.dll \
$(GTK_TOP)/bin/libgdk_pixbuf-2.0-0.dll \
$(GTK_TOP)/bin/libglib-2.0-0.dll \
$(GTK_TOP)/bin/libgmodule-2.0-0.dll \
$(GTK_TOP)/bin/libgobject-2.0-0.dll \
- $(GTK_TOP)/bin/libgthread-2.0-0.dll \
- $(GTK_TOP)/bin/libgtk-win32-2.0-0.dll \
$(GTK_TOP)/bin/libpango-1.0-0.dll \
- $(GTK_TOP)/bin/libpangocairo-1.0-0.dll \
- $(GTK_TOP)/bin/libpangoft2-1.0-0.dll \
$(GTK_TOP)/bin/libpangowin32-1.0-0.dll \
- $(GTK_TOP)/bin/libpng13.dll \
+ $(GTK_TOP)/bin/libpangoft2-1.0-0.dll \
+ $(GTK_TOP)/bin/libgtk-win32-2.0-0.dll \
+ $(GTK_TOP)/bin/libatk-1.0-0.dll \
+ $(GTK_TOP)/bin/libfontconfig-1.dll \
$(GTK_TOP)/bin/zlib1.dll \
+ $(GTK_TOP)/bin/libgthread-2.0-0.dll \
$(GTK_TOP)/expat/bin/xmlparse.dll \
$(GTK_TOP)/expat/bin/xmltok.dll \
- $(LIBXML2_TOP)/bin/libxml2.dll \
- $(SDL_TOP)/bin/SDL.dll \
- $(SDL_TOP)/bin/SDL_mixer.dll \
- $(GNUCHESS_TOP)/bin/pthreadGC.dll
+ $(GTK_TOP)/bin/iconv.dll \
+ $(GTK_TOP)/bin/intl.dll \
+ $(GTK_TOP)/bin/libpng12.dll \
+ $(GTK_TOP)/bin/jpeg62.dll
NEEDED_FILES = README \
- README.mingw \
- README.windows \
+ COPYING \
COPYING \
Changelog
@@ -93,10 +89,6 @@ prepack:
cp -r $(GTK_TOP)/lib/locale $(GCOMPRIS_INSTALL_DIR)/lib
cp -r $(GTK_TOP)/lib/gtk-2.0 $(GCOMPRIS_INSTALL_DIR)/lib
cp -r $(GTK_TOP)/lib/pango $(GCOMPRIS_INSTALL_DIR)/lib
- cp -r $(GCOMPRIS_BOARDS)/python $(GCOMPRIS_INSTALL_DIR)/share/gcompris
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/Makefile*
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/gcompris/Makefile*
- rm -f $(GCOMPRIS_INSTALL_DIR)/share/gcompris/python/admin/Makefile*
installer:
diff --git a/config.h.mingw b/config.h.mingw
index bad4cfd..c7634f0 100644
--- a/config.h.mingw
+++ b/config.h.mingw
@@ -2,7 +2,7 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Version number of package */
-#define VERSION "8.1"
+#define VERSION "8.2"
/* Supported languages */
#define ALL_LINGUAS "am ar az bg ca cs da de el en_CA en_GB es et fi fr ga gu he hi hr hu it lt mk ml ms nl nb nn pa pl pt pt_BR ro ru sk sl sq sr sr@Latn sv tr wa zh_CN"
diff --git a/configure.in b/configure.in
index 5a32baa..c3d1c47 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/gcompris/gcompris.c)
AC_CANONICAL_TARGET
-AM_INIT_AUTOMAKE(gcompris, 8.1)
+AM_INIT_AUTOMAKE(gcompris, 8.2)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
diff --git a/src/boards/algebra.c b/src/boards/algebra.c
index d7e6c28..4075692 100644
--- a/src/boards/algebra.c
+++ b/src/boards/algebra.c
@@ -52,16 +52,18 @@ static char *expected_result = NULL;
static gboolean operation_done[11];
-typedef struct {
+typedef struct _ToBeFoundItem ToBeFoundItem;
+
+struct _ToBeFoundItem{
guint index;
GnomeCanvasItem *item;
GnomeCanvasItem *focus_item;
GnomeCanvasItem *bad_item;
- char *next; /* Help : Should point to a ToBeFoundItem but don't know how to recurse on it */
- char *previous;
+ ToBeFoundItem *next;
+ ToBeFoundItem *previous;
char value;
gboolean in_error;
-} ToBeFoundItem;
+};
static ToBeFoundItem *currentToBeFoundItem = NULL;
static GnomeCanvasGroup *boardRootItem = NULL;
@@ -378,7 +380,7 @@ static void algebra_destroy_item(GnomeCanvasItem *item)
static void algebra_destroy_all_items()
{
GnomeCanvasItem *item;
- gboolean stop = FALSE;
+ ToBeFoundItem *next;
gc_timer_end();
@@ -388,29 +390,12 @@ static void algebra_destroy_all_items()
algebra_destroy_item(item);
}
- if(currentToBeFoundItem!=NULL)
- {
- /* Move toBeFoundItem to the most next digit */
- while(!stop)
- {
- if(currentToBeFoundItem->next!=NULL)
- currentToBeFoundItem = (ToBeFoundItem *)currentToBeFoundItem->next;
- else
- stop = TRUE;
- }
-
- /* Now free toBeFoundItems */
- while(!stop)
- {
- if(currentToBeFoundItem->previous!=NULL)
- {
- currentToBeFoundItem = (ToBeFoundItem *)currentToBeFoundItem->previous;
- free(currentToBeFoundItem->next);
- }
- else
- stop = TRUE;
- }
- }
+ while(currentToBeFoundItem)
+ {
+ next = currentToBeFoundItem -> next;
+ g_free(currentToBeFoundItem);
+ currentToBeFoundItem = next;
+ }
if(boardRootItem!=NULL)
gtk_object_destroy (GTK_OBJECT(boardRootItem));
@@ -484,12 +469,12 @@ static void display_operand(GnomeCanvasGroup *parent,
toBeFoundItem->value='?';
toBeFoundItem->item=item;
toBeFoundItem->focus_item=focus_item;
- toBeFoundItem->previous=(char *)previousToBeFoundItem;
+ toBeFoundItem->previous=previousToBeFoundItem;
toBeFoundItem->next=NULL;
/* I Create a double linked list with the toBeFoundItem in order to navigate through them */
if(previousToBeFoundItem!=NULL)
- previousToBeFoundItem->next=(char *)toBeFoundItem;
+ previousToBeFoundItem->next=toBeFoundItem;
previousToBeFoundItem=toBeFoundItem;
diff --git a/src/boards/canal_lock.c b/src/boards/canal_lock.c
index c43a12f..5c8f305 100644
--- a/src/boards/canal_lock.c
+++ b/src/boards/canal_lock.c
@@ -287,6 +287,7 @@ static GnomeCanvasItem *canal_lock_create_item(GnomeCanvasGroup *parent)
(GtkSignalFunc) gc_item_focus_event,
NULL);
tuxboat_width = gdk_pixbuf_get_width(pixmap);
+ gdk_pixbuf_unref(pixmap);
/* This is the ground canal */
gnome_canvas_item_new (boardRootItem,
diff --git a/src/boards/hanoi.c b/src/boards/hanoi.c
index dd9047a..d3be5c0 100644
--- a/src/boards/hanoi.c
+++ b/src/boards/hanoi.c
@@ -146,6 +146,7 @@ static void pause_board (gboolean pause)
*/
static void start_board (GcomprisBoard *agcomprisBoard)
{
+ gchar *img;
if(agcomprisBoard!=NULL)
{
@@ -157,8 +158,8 @@ static void start_board (GcomprisBoard *agcomprisBoard)
gc_bar_set(GC_BAR_LEVEL);
gc_set_background(gnome_canvas_root(gcomprisBoard->canvas),
- gc_skin_image_get("gcompris-bg.jpg"));
-
+ img = gc_skin_image_get("gcompris-bg.jpg"));
+ g_free(img);
hanoi_next_level();
gamewon = FALSE;
@@ -374,7 +375,7 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent)
/* Initialize a random goal and store the color index in position[number_of_item_x] */
for(i=0; i<(number_of_item_y); i++)
{
- guint color = (guint)RAND(0, NUMBER_OF_COLOR);
+ guint color = (guint)RAND(0, NUMBER_OF_COLOR-1);
position[number_of_item_x+1][i]->color = color;
used_colors[color] = TRUE;
@@ -411,12 +412,13 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent)
if(position[i][j]->color == -1)
{
/* Take only a color that is not part of the goal */
- guint color = (guint)RAND(0, NUMBER_OF_COLOR);
+ guint color = (guint)RAND(0, NUMBER_OF_COLOR-1);
//printf(" i,j=%d,%d random color = %d used_colors[color]=%d\n", i,j,color, used_colors[color]);
while(used_colors[color])
{
//printf(" used_colors[%d]=%d\n", color, used_colors[color]);
- if(color++>NUMBER_OF_COLOR)
+ color++;
+ if(color >= NUMBER_OF_COLOR)
color = 0;
}
diff --git a/src/boards/shapegame.c b/src/boards/shapegame.c
index fc28f2a..fa8bba2 100644
--- a/src/boards/shapegame.c
+++ b/src/boards/shapegame.c
@@ -1894,6 +1894,7 @@ add_xml_shape_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child)
g_free(soundfile);
g_free(name);
g_free(targetfile);
+ g_free(tooltip);
}
/* parse the doc, add it to our internal structures and to the clist */
diff --git a/src/gcompris/anim.c b/src/gcompris/anim.c
index 3bdb573..6f3a4b1 100644
--- a/src/gcompris/anim.c
+++ b/src/gcompris/anim.c
@@ -61,7 +61,7 @@ gc_anim_load(char *filename)
files = g_slist_append(files,
g_strdup_printf("%s/%s", gcomprisBoard->board_dir, tmp));
}
-
+ fclose(f);
anim = g_malloc(sizeof(GcomprisAnimation));
anim->numstates = g_slist_length(files);
anim->anim = g_malloc(sizeof(GdkPixbuf*) * anim->numstates);
@@ -145,6 +145,7 @@ gc_anim_free(GcomprisAnimation *anim)
{
g_object_unref(anim->anim[i]);
}
+ g_free(anim->anim);
g_free(anim);
}
diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c
index 7e45488..41792fb 100644
--- a/src/gcompris/gameutil.c
+++ b/src/gcompris/gameutil.c
@@ -265,11 +265,10 @@ gchar *reactivate_newline(char *str)
{
gchar *newstr;
- xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
-
if(str==NULL)
return NULL;
+ xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
newstr = (gchar *)xmlStringDecodeEntities(ctxt,
BAD_CAST str,
diff --git a/src/gcompris/gc_core.h b/src/gcompris/gc_core.h
index 01795a1..82ec355 100644
--- a/src/gcompris/gc_core.h
+++ b/src/gcompris/gc_core.h
@@ -41,6 +41,7 @@ int file_end_with_xml(const gchar *file);
/** menu */
void gc_menu_load();
+void gc_menu_destroy(void);
/** mimetype */
void gc_mime_type_load();
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index cdf843a..3f4aef5 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -996,6 +996,7 @@ static void cleanup()
gc_board_stop();
gc_db_exit();
gc_fullscreen_set(FALSE);
+ gc_menu_destroy();
gc_prop_destroy(gc_prop_get());
}
diff --git a/src/gcompris/images_selector.c b/src/gcompris/images_selector.c
index 4a81d6a..0bbd9ae 100644
--- a/src/gcompris/images_selector.c
+++ b/src/gcompris/images_selector.c
@@ -868,7 +868,10 @@ read_dataset_directory(gchar *dataset_dir)
g_warning("Reading dataset file %s", absolute_fname);
if (!g_file_test ((absolute_fname), G_FILE_TEST_EXISTS))
+ {
+ g_free(absolute_fname);
continue;
+ }
/* parse the new file and put the result into newdoc */
@@ -879,8 +882,11 @@ read_dataset_directory(gchar *dataset_dir)
/* in case something went wrong */
if(!doc)
+ {
+ g_free(absolute_fname);
continue;
-
+ }
+
if(/* if there is no root element */
!doc->children ||
/* if it doesn't have a name */
@@ -888,11 +894,13 @@ read_dataset_directory(gchar *dataset_dir)
/* if it isn't the good node */
g_strcasecmp((gchar *)doc->children->name, "ImageSetRoot")!=0) {
xmlFreeDoc(doc);
+ g_free(absolute_fname);
continue;
}
/* parse our document and replace old data */
g_warning("Parsing dataset : %s \n", absolute_fname);
+ g_free(absolute_fname);
parse_doc(doc);
xmlFreeDoc(doc);
diff --git a/src/gcompris/menu.c b/src/gcompris/menu.c
index 0cc91c7..77f45a5 100644
--- a/src/gcompris/menu.c
+++ b/src/gcompris/menu.c
@@ -35,6 +35,8 @@ GcomprisBoard *_read_xml_file(GcomprisBoard *gcomprisBoard, char *fname, gboolea
/* List of all available boards */
static GList *boards_list = NULL;
+void gc_menu_board_free(GcomprisBoard *board);
+
GList *gc_menu_get_boards()
{
return boards_list;
@@ -81,7 +83,10 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child,
g_free(path);
path = g_strdup("");
if (strcmp(gcomprisBoard->name,"root")==0)
- gcomprisBoard->name = "";
+ {
+ g_free(gcomprisBoard->name);
+ gcomprisBoard->name = g_strdup("");
+ }
}
gcomprisBoard->section = path;
@@ -95,7 +100,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child,
gcomprisBoard->difficulty = (char *)xmlGetProp(xmlnode, BAD_CAST "difficulty");
if(gcomprisBoard->difficulty == NULL)
- gcomprisBoard->difficulty = "0";
+ gcomprisBoard->difficulty = g_strdup("0");
/* Update the difficulty max */
if(properties->difficulty_max < atoi(gcomprisBoard->difficulty))
@@ -561,18 +566,15 @@ void gc_menu_load_dir(char *dirname, gboolean db){
if ((strncmp(board_read->section,
"/administration",
strlen("/administration"))!=0)) {
-
- if (gc_profile_get_current() &&
- !(g_list_find_custom(gc_profile_get_current()->activities,
- &(board_read->board_id), compare_id))) {
- boards_list = g_list_append(boards_list, board_read);
- } else {
boards_list = g_list_append(boards_list, board_read);
}
+ else
+ gc_menu_board_free(board_read);
}
}
+ else
+ gc_menu_board_free(gcomprisBoard);
}
- }
g_free(filename);
}
}
@@ -648,3 +650,50 @@ void gc_menu_load()
g_free(board_dir);
}
}
+
+
+void gc_menu_board_free(GcomprisBoard *board)
+{
+ if(strcmp(board->type,"shapegame")==0 ||
+ strncmp(board->type, "python", 6)==0)
+ {
+ g_free(board->plugin);
+ }
+ g_free(board->type);
+ g_free(board->board_dir);
+ g_free(board->mode);
+
+ g_free(board->name);
+ g_free(board->title);
+ g_free(board->description);
+ g_free(board->icon_name);
+ g_free(board->author);
+ g_free(board->boarddir);
+ g_free(board->filename);
+ g_free(board->difficulty);
+ g_free(board->mandatory_sound_file);
+ g_free(board->mandatory_sound_dataset);
+
+ g_free(board->section);
+ g_free(board->menuposition);
+
+ g_free(board->prerequisite);
+ g_free(board->goal);
+ g_free(board->manual);
+ g_free(board->credit);
+
+ if (board->gmodule)
+ g_module_close(board->gmodule);
+ g_free(board->gmodule_file);
+
+ g_free(board);
+}
+
+void gc_menu_destroy(void)
+{
+ GList * list;
+ for(list = boards_list ; list ; list = list -> next)
+ {
+ gc_menu_board_free((GcomprisBoard *) list->data);
+ }
+}
diff --git a/src/gcompris/soundutil.c b/src/gcompris/soundutil.c
index b3c0609..0a72889 100644
--- a/src/gcompris/soundutil.c
+++ b/src/gcompris/soundutil.c
@@ -438,7 +438,6 @@ gc_sound_alphabet(gchar *chars)
next = chars;
result = NULL;
- str = g_new0(gchar, 6);
for (i=0; i < length; i++) {
next_unichar = g_utf8_get_char(next);