Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
11 files changed, 96 insertions, 49 deletions
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);