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-09-19 23:27:12 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-09-19 23:27:12 (GMT)
commitf7a73e471773db5929e195804905c24e81ca5f9d (patch)
tree6a0f64b998c6c8acba7b2d3231d8b20d8a3fd089
parent2904455a54c26e304d7d1a6408d71ad334023c8d (diff)
- Memory leak review by miguel2i (on free.fr)
- Fixed chess movelearn level 3, white could take the king immediately. reported by woof.
-rw-r--r--ChangeLog33
-rw-r--r--Makefile.mingw4
-rw-r--r--src/boards/Makefile.mingw47
-rw-r--r--src/boards/chess_position.c162
-rw-r--r--src/boards/imageid.c2
-rw-r--r--src/boards/menu2.c12
-rw-r--r--src/boards/python.c1
-rw-r--r--src/gcompris/file_selector.c1
-rw-r--r--src/gcompris/gcompris.c1
-rw-r--r--src/gcompris/gcompris_confirm.c3
-rw-r--r--src/gcompris/gcompris_db.c6
-rw-r--r--src/gcompris/menu.c2
-rw-r--r--src/gcompris/profile.c17
-rw-r--r--src/gcompris/profile.h2
-rw-r--r--src/gcompris/properties.c39
-rw-r--r--src/gcompris/skin.c1
16 files changed, 228 insertions, 105 deletions
diff --git a/ChangeLog b/ChangeLog
index 09a762e..eb4c0a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2006-09-20 Bruno coudoin <bruno.coudoin@free.fr>
+
+ reviewed by: <delete if not using a buddy>
+
+ * Makefile.mingw:
+ * src/boards/Makefile.mingw:
+ * src/boards/chess_position.c: (position_set_empty),
+ (position_set_initial), (position_set_initial_partyend),
+ (position_set_initial_movelearn), (position_display),
+ (position_move_white), (position_move_black),
+ (position_move_normalize_promotion), (position_move_normalize),
+ (position_move_reverse_white), (position_move_reverse_black),
+ (wpawn2), (wpawn5), (wknight), (w_ro_l), (bdouble), (bpawn7),
+ (b_ro_k), (b_ro_l), (bkingro), (position_move_generator_white),
+ (position_move_generator_black), (position_move_generator),
+ (long4), (position_white_king_attack),
+ (position_black_king_attack), (position_legal_move):
+ * src/boards/imageid.c:
+ * src/boards/menu2.c: (menu_end), (set_content):
+ * src/boards/python.c: (pythonboard_init):
+ * src/gcompris/file_selector.c: (parseMime):
+ * src/gcompris/gcompris.c: (cleanup):
+ * src/gcompris/gcompris_confirm.c: (set_content):
+ * src/gcompris/gcompris_db.c: (gc_db_get_profile_from_id),
+ (gc_db_get_profile):
+ * src/gcompris/menu.c: (_add_xml_to_data):
+ * src/gcompris/profile.c: (gc_profile_set_current_user),
+ (gc_profile_destroy), (gc_user_destroy):
+ * src/gcompris/profile.h:
+ * src/gcompris/properties.c: (gc_prop_config_file_get),
+ (gc_prop_new), (gc_prop_destroy):
+ * src/gcompris/skin.c: (skin_xml_load):
+
*** RELEASE 8.0BETA6 ***
2006-09-18 Bruno coudoin <bruno.coudoin@free.fr>
diff --git a/Makefile.mingw b/Makefile.mingw
index 6c7739a..ca0c947 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -18,6 +18,7 @@ LIBXML2_TOP := /libxml2
SDL_TOP := /sdl
CANVAS_TOP := /gnomecanvas
GNUCHESS_TOP := /gnuchess
+PYTHON_TOP := /c/Python24
MAKENSIS := "/c/Program Files/NSIS/makensis.exe"
@@ -56,7 +57,8 @@ NEEDED_DLLS = $(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
+ $(GTK_TOP)/bin/jpeg62.dll \
+ /c/WINDOWS/system32/python24.dll
NEEDED_FILES = README \
COPYING \
diff --git a/src/boards/Makefile.mingw b/src/boards/Makefile.mingw
index b601011..83528e5 100644
--- a/src/boards/Makefile.mingw
+++ b/src/boards/Makefile.mingw
@@ -15,6 +15,7 @@ GNUWIN32_TOP := /gnuwin32
LIBXML2_TOP := /libxml2
SDL_TOP := /sdl
CANVAS_TOP := /gnomecanvas
+PYTHON_TOP := /c/Python24
GCOMPRIS_INSTALL_DIR := $(GCOMPRIS_TOP)/win32-install-dir
##
@@ -55,14 +56,18 @@ INCLUDE_PATHS += -I$(GCOMPRIS_PLUGINS) \
-I$(LIBXML2_TOP)/include \
-I$(GNUWIN32_TOP)/include \
-I$(GCOMPRIS_TOP) \
- -I$(GCOMPRIS_TOP)/src
+ -I$(GCOMPRIS_TOP)/src \
+ -I$(PYTHON_TOP)/include \
+ -I$(PYTHON_TOP)/include/pygtk-2.0
+
LIB_PATHS = -L$(GTK_TOP)/lib \
-L$(LIBXML2_TOP)/lib \
-L$(GNUWIN32_TOP)/lib \
-L$(SDL_TOP)/lib \
- -L$(GCOMPRIS_TOP)/src/gcompris
+ -L$(GCOMPRIS_TOP)/src/gcompris \
+ -I$(PYTHON_TOP)/lib
##
@@ -84,6 +89,8 @@ LIBS = -lgtk-win32-2.0 \
-lgdi32 -lgthread-2.0 \
-lintl \
-lws2_32 \
+ -lpython \
+ -lpython24 \
libgcompris-1.la
##
@@ -103,6 +110,37 @@ install:
##
## SOURCES, OBJECTS
##
+PYTHON_C_SRC = \
+ python.c \
+ py-gcompris-board.c \
+ py-gcompris-board.h \
+ py-gcompris-properties.c \
+ py-gcompris-properties.h \
+ py-gcompris-profile.c \
+ py-gcompris-profile.h \
+ py-gcompris-wordlist.c \
+ py-gcompris-wordlist.h \
+ py-gcompris-user.c \
+ py-gcompris-class.c \
+ py-gcompris-group.c \
+ py-mod-gcompris.c \
+ py-mod-gcompris.h \
+ py-mod-utils.c \
+ py-mod-utils.h \
+ py-mod-admin.c \
+ py-mod-admin.h \
+ py-mod-bonus.c \
+ py-mod-bonus.h \
+ py-mod-score.c \
+ py-mod-score.h \
+ py-mod-timer.c \
+ py-mod-timer.h \
+ py-mod-sound.c \
+ py-mod-sound.h \
+ py-mod-skin.c \
+ py-mod-skin.h \
+ py-mod-anim.c \
+ py-mod-anim.h
BOARDS_C_SRC = \
algebra.c \
@@ -145,12 +183,13 @@ BOARDS_C_SRC = \
traffic.c \
wordsgame.c \
advanced_colors.c \
- read_colors.c
+ read_colors.c \
+ $(PYTHON_C_SRC)
-BOARDS_OBJECTS = $(BOARDS_C_SRC:%.c=%.o)
+BOARDS_OBJECTS = $(BOARDS_C_SRC:%.c=%.o)
#
diff --git a/src/boards/chess_position.c b/src/boards/chess_position.c
index c56dae7..0b0f793 100644
--- a/src/boards/chess_position.c
+++ b/src/boards/chess_position.c
@@ -41,8 +41,8 @@ struct _PositionPrivate {
};
/* Move generation variables */
-static const int jump [] = { 8, 12,19, 21,-8,-12,-19,-21,
- 9, 11,-9,-11, 1, 10,-10, -1,
+static const int jump [] = { 8, 12,19, 21,-8,-12,-19,-21,
+ 9, 11,-9,-11, 1, 10,-10, -1,
9, 11, 1, 10,-1, 1, 10, -1,
-9,-11, 1,-10,-1 };
static Square *nindex, *sindex;
@@ -137,7 +137,7 @@ position_copy (Position *pos)
static void
position_set_empty (Position *pos)
{
- unsigned int a;
+ unsigned int a;
for (a = 0 ; a < 120 ; a++)
pos->square [a] = EMPTY;
@@ -159,7 +159,7 @@ position_set_empty (Position *pos)
pos->priv->br_a_move = 0;
pos->priv->captured = EMPTY;
- pos->priv->tomove = NONE;
+ pos->priv->tomove = NONE;
}
void
@@ -188,7 +188,7 @@ position_set_initial (Position *pos)
pos->square [H8] = BR;
/* Pawns on the 2nd and 7th ranks */
- for (a = A2; a <= H2 ;a++)
+ for (a = A2; a <= H2 ;a++)
pos->square [a] = WP;
for (a = A7; a <= H7 ;a++)
pos->square [a] = BP;
@@ -220,8 +220,8 @@ position_set_initial_partyend (Position *pos, int level)
register Square square;
register gshort rank;
- for (rank = 1; rank <= 8; rank++) {
- for (square = A1 + ((rank - 1) * 10);
+ for (rank = 1; rank <= 8; rank++) {
+ for (square = A1 + ((rank - 1) * 10);
square <= H1 + ((rank - 1) * 10);
square++) {
pos->square [square] = EMPTY;
@@ -235,7 +235,7 @@ position_set_initial_partyend (Position *pos, int level)
pos->square [A1] = WK;
pos->square [G1] = WQ;
pos->square [F1] = WQ;
-
+
/* The black pieces */
pos->square [E8] = BK;
@@ -248,7 +248,7 @@ position_set_initial_partyend (Position *pos, int level)
pos->square [E1] = WK;
pos->square [F1] = WR;
pos->square [G1] = WR;
-
+
/* The black pieces */
pos->square [A8] = BK;
@@ -261,7 +261,7 @@ position_set_initial_partyend (Position *pos, int level)
pos->square [E1] = WK;
pos->square [B4] = WR;
pos->square [B5] = WB;
-
+
/* The black pieces */
pos->square [A1] = BK;
@@ -286,8 +286,8 @@ position_set_initial_movelearn (Position *pos, int level)
register Square square;
register gshort rank;
- for (rank = 1; rank <= 8; rank++) {
- for (square = A1 + ((rank - 1) * 10);
+ for (rank = 1; rank <= 8; rank++) {
+ for (square = A1 + ((rank - 1) * 10);
square <= H1 + ((rank - 1) * 10);
square++) {
pos->square [square] = EMPTY;
@@ -300,7 +300,7 @@ position_set_initial_movelearn (Position *pos, int level)
/* The white pieces */
pos->square [E1] = WK;
pos->square [B4] = WR;
-
+
/* The black pieces */
pos->square [A1] = BK;
pos->square [E7] = BP;
@@ -313,7 +313,7 @@ position_set_initial_movelearn (Position *pos, int level)
/* The white pieces */
pos->square [E1] = WK;
pos->square [G1] = WQ;
-
+
/* The black pieces */
pos->square [A1] = BK;
pos->square [E7] = BP;
@@ -326,8 +326,8 @@ position_set_initial_movelearn (Position *pos, int level)
/* The white pieces */
pos->square [E1] = WK;
pos->square [C4] = WB;
- pos->square [D4] = WB;
-
+ pos->square [C5] = WB;
+
/* The black pieces */
pos->square [A1] = BK;
pos->square [E7] = BP;
@@ -341,7 +341,7 @@ position_set_initial_movelearn (Position *pos, int level)
pos->square [E1] = WK;
pos->square [B4] = WN;
pos->square [B5] = WN;
-
+
/* The black pieces */
pos->square [A1] = BK;
pos->square [E7] = BP;
@@ -358,7 +358,7 @@ position_set_initial_movelearn (Position *pos, int level)
pos->square [F2] = WP;
pos->square [G2] = WP;
pos->square [H2] = WP;
-
+
/* The black pieces */
pos->square [A1] = BK;
pos->square [E7] = BP;
@@ -385,8 +385,8 @@ position_display (Position *pos)
register Square square;
register gshort rank;
- for (rank = 8; rank >= 1; rank--) {
- for (square = A1 + ((rank - 1) * 10);
+ for (rank = 8; rank >= 1; rank--) {
+ for (square = A1 + ((rank - 1) * 10);
square <= H1 + ((rank - 1) * 10);
square++) {
@@ -395,10 +395,10 @@ position_display (Position *pos)
g_warning("\n");
}
}
-/*
+/*
* Move Functions
*
- * A set of functions to make a move in the context of the position
+ * A set of functions to make a move in the context of the position
* passed in.
*/
static void
@@ -445,7 +445,7 @@ position_move_white (Position *pos, Square from, Square to)
case WP :
/* If we are promoting a pawn */
if (to & 128) {
- new_to = (to & 7) + A8;
+ new_to = (to & 7) + A8;
piece = ((to & 127) >> 3 ) + WP - 1;
pos->priv->captured = pos->square [new_to];
@@ -475,7 +475,7 @@ position_move_white (Position *pos, Square from, Square to)
if ((to - from) == 20)
pos->priv->ep = to;
- else
+ else
pos->priv->ep = EMPTY;
return;
@@ -488,7 +488,7 @@ position_move_white (Position *pos, Square from, Square to)
/* If we are not castling */
if (from != E1 || abs (to - from) != 2) {
pos->priv->captured = pos->square [to];
- pos->square [to] = piece;
+ pos->square [to] = piece;
pos->square [from] = EMPTY;
return;
}
@@ -497,11 +497,11 @@ position_move_white (Position *pos, Square from, Square to)
switch (to) {
case G1 :
position_move_white_castle_short (pos);
- break;
+ break;
case C1 :
position_move_white_castle_long (pos);
- break;
- default :
+ break;
+ default :
abort ();
}
return;
@@ -562,8 +562,8 @@ position_move_black (Position *pos, Square from, Square to)
if ((from - to) == 20)
pos->priv->ep = to;
- else
- pos->priv->ep = EMPTY;
+ else
+ pos->priv->ep = EMPTY;
return;
case BK :
@@ -582,12 +582,12 @@ position_move_black (Position *pos, Square from, Square to)
/* If we are castling */
switch (to) {
- case G8 :
+ case G8 :
position_move_black_castle_short (pos);
- break;
+ break;
case C8 :
position_move_black_castle_long (pos);
- break;
+ break;
default :
abort();
}
@@ -642,14 +642,14 @@ position_move_normalize_promotion (Position *pos, Square to, gshort n1,
/* Automatic queen promotion prefs_get_promotetoqueen */
c = 0;
- if (pos->priv->tomove == WHITE)
+ if (pos->priv->tomove == WHITE)
switch (c) {
case 0 : fi = WQ; break;
case 1 : fi = WR; break;
case 2 : fi = WB; break;
case 3 : fi = WN; break;
}
- else
+ else
switch (c) {
case 0 : fi = BQ; break;
case 1 : fi = BR; break;
@@ -670,7 +670,7 @@ position_move_normalize_promotion (Position *pos, Square to, gshort n1,
return n3;
if (help == n4)
return n4;
-
+
}
return FALSE;
}
@@ -688,9 +688,9 @@ position_move_normalize (Position *pos, Square from, Square to)
for (aq = ap, i = 0; i < legal_moves; i++, aq += 2 ) {
if (from == *aq) {
- if (to == *(aq + 1))
+ if (to == *(aq + 1))
return to;
- else if (*(aq + 1) & 128) {
+ else if (*(aq + 1) & 128) {
/* Promotion */
ret = position_move_normalize_promotion (
pos, to, *(aq + 1), *(aq + 3),
@@ -705,10 +705,10 @@ position_move_normalize (Position *pos, Square from, Square to)
return FALSE;
}
-/*
+/*
* Move Reverse Functions
*
- * A set of functions to reverse a previous move in the context of the position
+ * A set of functions to reverse a previous move in the context of the position
* passed in.
*
*/
@@ -759,7 +759,7 @@ position_move_reverse_promotion_black (Position *pos, Square from, Square to)
}
void
-position_move_reverse_white (Position *pos, Square from, Square to)
+position_move_reverse_white (Position *pos, Square from, Square to)
{
Piece fi;
@@ -778,7 +778,7 @@ position_move_reverse_white (Position *pos, Square from, Square to)
pos->priv->wk_square = from;
pos->priv->wr_a_move -= 1;
pos->priv->wr_h_move -= 1;
-
+
if (from != E1) { /* no castling */
pos->square[from] = fi;
pos->square[to] = pos->priv->captured;
@@ -825,7 +825,7 @@ position_move_reverse_white (Position *pos, Square from, Square to)
}
void
-position_move_reverse_black (Position *pos, Square from, Square to)
+position_move_reverse_black (Position *pos, Square from, Square to)
{
int fi;
@@ -844,7 +844,7 @@ position_move_reverse_black (Position *pos, Square from, Square to)
pos->priv->bk_square = from;
pos->priv->br_a_move -= 1;
pos->priv->br_h_move -= 1;
-
+
if (from != E8) { /* no castling */
pos->square[from] = fi;
pos->square[to] = pos->priv->captured;
@@ -905,10 +905,10 @@ position_move_reverse (Position *pos, Square from, Square to)
}
}
-/*
+/*
* Move Generation Functions
*
- * A set of functions to generate moves in the context of the position
+ * A set of functions to generate moves in the context of the position
* passed in.
*
*/
@@ -921,7 +921,7 @@ new_move (Square from, Square to)
nindex += 2;
}
-static void
+static void
new_capture_move (Square from, Square to)
{
sindex -= 2;
@@ -975,7 +975,7 @@ wpawn2 (Position *pos, Square from)
{
register Square to;
- to = from + 10;
+ to = from + 10;
if (pos->square[to] == EMPTY ) {
new_move (from, to);
to = from + 20;
@@ -1009,7 +1009,7 @@ wpawn5 (Position *pos, Square from)
{
wpawn3 (pos, from);
- if ((from - 1) == pos->priv->ep)
+ if ((from - 1) == pos->priv->ep)
new_capture_move (from, from + 9);
else if ((from + 1) == pos->priv->ep)
new_capture_move (from, from + 11);
@@ -1045,7 +1045,7 @@ wknight (Position *pos, gshort from)
case EMPTY:
new_move (from, to);
break;
- case BORDER:
+ case BORDER:
break;
default:
if (BPIECE (piece))
@@ -1117,7 +1117,7 @@ w_ro_l (Position *pos)
if (pos->square[D1] == EMPTY &&
pos->square[C1] == EMPTY &&
pos->square[B1] == EMPTY &&
- pos->square[A1] == WR)
+ pos->square[A1] == WR)
new_move (E1, C1);
}
@@ -1170,7 +1170,7 @@ bdouble (Position *pos, Square from, gshort a, gshort b)
new_move (from, to);
else if (piece == BORDER)
break;
- else if (WPIECE (piece)) {
+ else if (WPIECE (piece)) {
new_capture_move (from, to);
break;
} else {
@@ -1197,10 +1197,10 @@ bpawn7 (Position *pos, Square from)
{
register Square to;
- to = from - 10;
+ to = from - 10;
if (pos->square[to] == EMPTY) {
new_move (from, to);
- to = from - 20;
+ to = from - 20;
if (pos->square[to] == EMPTY)
new_move (from, to);
}
@@ -1328,7 +1328,7 @@ static
void b_ro_k (Position *pos)
{
if (pos->square[F8] == EMPTY &&
- pos->square[G8] == EMPTY &&
+ pos->square[G8] == EMPTY &&
pos->square[H8] == BR)
new_move (E8, G8);
@@ -1340,12 +1340,12 @@ void b_ro_l (Position *pos)
if (pos->square[D8] == EMPTY &&
pos->square[C8] == EMPTY &&
pos->square[B8] == EMPTY &&
- pos->square[A8] == BR)
+ pos->square[A8] == BR)
new_move(E8, C8);
}
static void
-bkingro (Position *pos, Square from)
+bkingro (Position *pos, Square from)
{
register Square to;
register Piece piece;
@@ -1370,7 +1370,7 @@ bkingro (Position *pos, Square from)
if ( pos->priv->bk_square != E8)
return;
if (!pos->priv->br_h_move)
- b_ro_k (pos);
+ b_ro_k (pos);
if (!pos->priv->br_a_move)
b_ro_l (pos);
}
@@ -1384,8 +1384,8 @@ position_move_generator_white (Position *pos, Square **index0, gshort *anz_s, gs
nindex = sindex = *index0;
- for (rank = 1; rank <= 8; rank++) {
- for (square = A1 + ((rank - 1) * 10);
+ for (rank = 1; rank <= 8; rank++) {
+ for (square = A1 + ((rank - 1) * 10);
square <= H1 + ((rank - 1) * 10);
square++) {
piece = pos->square[square];
@@ -1394,7 +1394,7 @@ position_move_generator_white (Position *pos, Square **index0, gshort *anz_s, gs
continue;
switch (piece) {
- case WP:
+ case WP:
switch (rank) {
case 1:
case 8:
@@ -1429,7 +1429,7 @@ position_move_generator_white (Position *pos, Square **index0, gshort *anz_s, gs
wqueen (pos, square);
break;
case WK:
- if (rank == 1)
+ if (rank == 1)
wkingro (pos, square);
else
wking (pos, square);
@@ -1454,16 +1454,16 @@ position_move_generator_black (Position *pos, Square **index0, gshort *anz_s, gs
nindex = sindex = *index0;
- for (rank = 1; rank <= 8; rank++) {
+ for (rank = 1; rank <= 8; rank++) {
for (square = A1 + ((rank - 1) * 10);
square <= H1 + ((rank - 1) * 10);
square++ ) {
piece = pos->square[square];
if (!BPIECE (piece))
continue;
-
+
switch (piece) {
- case BP:
+ case BP:
switch (rank) {
case 1:
case 8:
@@ -1498,7 +1498,7 @@ position_move_generator_black (Position *pos, Square **index0, gshort *anz_s, gs
bqueen (pos, square);
break;
case BK:
- if (rank == 8)
+ if (rank == 8)
bkingro (pos, square);
else
bking (pos, square);
@@ -1510,7 +1510,7 @@ position_move_generator_black (Position *pos, Square **index0, gshort *anz_s, gs
*anz_n = (gshort) ((nindex - *index0) / 2);
*anz_s = (gshort) ((*index0 - sindex) / 2);
*index0 = sindex;
-
+
return *anz_n + *anz_s;
}
@@ -1519,15 +1519,15 @@ position_move_generator (Position *pos, Square **index0,
gshort *anz_s, gshort *anz_n)
{
- if (pos->priv->tomove == WHITE )
+ if (pos->priv->tomove == WHITE )
return position_move_generator_white (pos, index0, anz_s, anz_n);
- else if (pos->priv->tomove == BLACK )
+ else if (pos->priv->tomove == BLACK )
return position_move_generator_black (pos, index0, anz_s, anz_n);
else
abort();
}
-/*
+/*
* Position Characteristic Functions
*
* A set of functions to give information about the position
@@ -1552,7 +1552,7 @@ static int long4 (Position *pos, int ort, int r1, int r2, int r3, int r4, int f1
CHECK (ort,r4,f1,f2);
return FALSE;
-}
+}
#define KURZ_TEST(r) if (pos->square[ort+r] == f1) return f1
@@ -1584,16 +1584,16 @@ position_white_king_attack (Position *pos)
ret = long4 (pos, k, 9, 11, -9, -11, BQ, BB);
if (ret)
return ret;
-
+
ret = long4 (pos, k, 1, 10, -10, -1, BQ, BR);
if (ret)
return ret;
-
+
if (short8 (pos, k, 8, 12, 19, 21, -8, -12, -19, -21, BN))
return BN;
if (short8 (pos, k, 9, 11, -9, -11, 1, 10, -10, -1, BK))
return BK;
-
+
if (pos->square[k+OL] == BP)
return BP;
if (pos->square[k+OR] == BP)
@@ -1610,20 +1610,20 @@ position_black_king_attack (Position *pos)
g_return_val_if_fail (pos != NULL, 0);
g_return_val_if_fail (IS_POSITION (pos), 0);
-
+
ret = long4 (pos, k, 9, 11, -9, -11, WQ, WB);
if (ret)
return ret;
-
+
ret = long4 (pos, k, 1, 10, -10, -1, WQ, WR);
if (ret)
return ret;
-
+
if (short8 (pos, k, 8, 12, 19, 21, -8, -12, -19, -21, WN))
return WN;
if (short8 (pos, k, 9, 11, -9, -11, 1, 10, -10, -1, WK))
return WK;
-
+
if (pos->square[k+UL] == WP)
return WP;
if (pos->square[k+UR] == WP)
@@ -1656,7 +1656,7 @@ position_legal_move (Position *pos, Square **zl, gshort *as, gshort *an)
position_move (pos, *ap, *(ap+1));
switch (tomove) {
- case WHITE:
+ case WHITE:
check = position_white_king_attack (pos);
break;
case BLACK:
@@ -1675,11 +1675,11 @@ position_legal_move (Position *pos, Square **zl, gshort *as, gshort *an)
}
switch (tomove) {
case WHITE:
- position_move_reverse_white (pos, *(ap - 2),
+ position_move_reverse_white (pos, *(ap - 2),
*(ap - 1));
break;
case BLACK:
- position_move_reverse_black (pos, *(ap - 2),
+ position_move_reverse_black (pos, *(ap - 2),
*(ap - 1));
break;
}
diff --git a/src/boards/imageid.c b/src/boards/imageid.c
index 53f9b04..6ba0b5f 100644
--- a/src/boards/imageid.c
+++ b/src/boards/imageid.c
@@ -17,8 +17,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define DEBUG 0
-
#include <ctype.h>
#include <math.h>
#include <assert.h>
diff --git a/src/boards/menu2.c b/src/boards/menu2.c
index 84f0628..ac4c92f 100644
--- a/src/boards/menu2.c
+++ b/src/boards/menu2.c
@@ -91,8 +91,6 @@ static double icon_size, icon_size_panel, icon_size_top, top_arrow_size;
static gdouble get_ratio(GdkPixbuf *pixmap, gdouble size);
-GList *homeBoards = NULL;
-
#define P_X 10
#define P_Y 10
#define P_W 90
@@ -391,6 +389,9 @@ menu_end ()
boardRootItem = NULL;
actualSectionItem = NULL;
+
+ g_list_free(panelBoards);
+
}
static gboolean
@@ -708,6 +709,7 @@ set_content(GnomeCanvasRichText *item_content,
color_string = g_strdup_printf("#%x", gc_skin_color_shadow >> 8);
gdk_color_parse(color_string, color_s);
+ g_free(color_string);
success = gdk_colormap_alloc_color(gdk_colormap_get_system(),
color_s,
FALSE, TRUE);
@@ -721,13 +723,12 @@ set_content(GnomeCanvasRichText *item_content,
gtk_text_buffer_get_start_iter(buffer, &iter_start);
gtk_text_buffer_apply_tag(buffer, txt_tag, &iter_start, &iter_end);
- g_free(color_string);
-
/*
* Set the text
*/
color_string = g_strdup_printf("#%x", gc_skin_get_color("menu/text") >> 8);
gdk_color_parse(color_string, color);
+ g_free(color_string);
success = gdk_colormap_alloc_color(gdk_colormap_get_system(),
color,
FALSE, TRUE);
@@ -740,7 +741,8 @@ set_content(GnomeCanvasRichText *item_content,
gtk_text_buffer_get_end_iter(buffer, &iter_end);
gtk_text_buffer_get_start_iter(buffer, &iter_start);
gtk_text_buffer_apply_tag(buffer, txt_tag, &iter_start, &iter_end);
-
+ g_free(color);
+ g_free(color_s);
}
/** \brief create the area in which we display the board title and description
diff --git a/src/boards/python.c b/src/boards/python.c
index 9a6095b..ce2d834 100644
--- a/src/boards/python.c
+++ b/src/boards/python.c
@@ -146,7 +146,6 @@ pythonboard_init (GcomprisBoard *agcomprisBoard){
pythonboard_is_ready = FALSE;
} else {
/* Add the python plugins dir to the python's search path */
- execstr = g_strdup_printf("import sys; sys.path.append('%s')",properties->package_python_plugin_dir);
#ifndef DISABLE_USER_PLUGIN_DIR
userplugindir = g_strconcat(g_get_home_dir(), "/.gcompris/Plugins/", NULL);
execstr = g_strdup_printf("import sys; sys.path.append('%s/python'); sys.path.append('%s')",
diff --git a/src/gcompris/file_selector.c b/src/gcompris/file_selector.c
index 7a38c89..acf8c0d 100644
--- a/src/gcompris/file_selector.c
+++ b/src/gcompris/file_selector.c
@@ -825,6 +825,7 @@ void parseMime (xmlDocPtr doc, xmlNodePtr xmlnode) {
gcomprisMime->description = (gchar *)xmlNodeListGetString(doc,
xmlnode->xmlChildrenNode, 1);
}
+ g_free(lang);
xmlnode = xmlnode->next;
}
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index cc81c72..109d112 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -941,6 +941,7 @@ static void cleanup()
gc_board_stop();
gc_db_exit();
+ gc_prop_destroy(gc_prop_get());
gc_fullscreen_set(FALSE);
}
diff --git a/src/gcompris/gcompris_confirm.c b/src/gcompris/gcompris_confirm.c
index 24a9e16..6cad190 100644
--- a/src/gcompris/gcompris_confirm.c
+++ b/src/gcompris/gcompris_confirm.c
@@ -453,6 +453,9 @@ set_content(GnomeCanvasRichText *item_content,
gtk_text_buffer_get_start_iter(buffer, &iter_start);
gtk_text_buffer_apply_tag(buffer, txt_tag, &iter_start, &iter_end);
+ g_free(color);
+ g_free(color_s);
+
}
static gint
diff --git a/src/gcompris/gcompris_db.c b/src/gcompris/gcompris_db.c
index ae0cc5a..8055b9e 100644
--- a/src/gcompris/gcompris_db.c
+++ b/src/gcompris/gcompris_db.c
@@ -857,7 +857,7 @@ GcomprisProfile *gc_db_get_profile_from_id(gint profile_id)
profile->name = g_strdup(result[3]);
profile->directory = g_strdup(result[4]);
profile->description = g_strdup(result[5]);
-
+ sqlite3_free_table(result);
g_free(request);
request = g_strdup_printf(GET_GROUPS_IN_PROFILE(profile->profile_id));
@@ -891,6 +891,7 @@ GcomprisProfile *gc_db_get_profile_from_id(gint profile_id)
}
profile->group_ids = ids;
}
+ sqlite3_free_table(result);
request = g_strdup_printf(GET_ACTIVITIES_OUT_OF_PROFILE(profile->profile_id));
rc = sqlite3_get_table(gcompris_db,
@@ -922,6 +923,7 @@ GcomprisProfile *gc_db_get_profile_from_id(gint profile_id)
}
profile->activities = ids;
}
+ sqlite3_free_table(result);
}
return profile;
@@ -1011,6 +1013,8 @@ GcomprisProfile *gc_db_get_profile()
profile_id = atoi(result[1]);
+ sqlite3_free_table(result);
+
return gc_db_get_profile_from_id(profile_id);
#else
diff --git a/src/gcompris/menu.c b/src/gcompris/menu.c
index 9952a9f..ce815a0 100644
--- a/src/gcompris/menu.c
+++ b/src/gcompris/menu.c
@@ -112,6 +112,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child,
{
title = (char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0);
gcomprisBoard->title = reactivate_newline(gettext(title));
+ g_free(title);
}
/* get the description of the board */
@@ -119,6 +120,7 @@ _add_xml_to_data(xmlDocPtr doc, xmlNodePtr xmlnode, GNode * child,
{
description = (char *)xmlNodeListGetString(doc, xmlnode->xmlChildrenNode, 0);
gcomprisBoard->description = reactivate_newline(gettext(description));
+ g_free(description);
}
/* get the help prerequisite help of the board */
diff --git a/src/gcompris/profile.c b/src/gcompris/profile.c
index 5e7bb41..69c3418 100644
--- a/src/gcompris/profile.c
+++ b/src/gcompris/profile.c
@@ -76,9 +76,26 @@ gc_profile_set_current_user(GcomprisUser *user)
gchar *session_id_str = g_strdup_printf("%s%ld%ld", (properties->logged_user)->login, now.tv_sec, now.tv_usec);
(properties->logged_user)->session_id = g_str_hash((gconstpointer) session_id_str);
+ g_free(session_id_str);
}
+void gc_profile_destroy(GcomprisProfile*prof)
+{
+ g_free(prof->name);
+ g_free(prof->directory);
+ g_free(prof->description);
+ g_free(prof);
+}
+
+void gc_user_destroy(GcomprisUser*user)
+{
+ g_free(user->login);
+ g_free(user->lastname);
+ g_free(user->firstname);
+ g_free(user->birthdate);
+ g_free(user);
+}
GcomprisUser*
gc_profile_get_current_user()
diff --git a/src/gcompris/profile.h b/src/gcompris/profile.h
index 736c126..e8150d4 100644
--- a/src/gcompris/profile.h
+++ b/src/gcompris/profile.h
@@ -138,6 +138,8 @@ typedef struct {
/* Active profile */
GcomprisProfile *gc_profile_get_current();
+void gc_profile_destroy(GcomprisProfile *prof);
+void gc_user_destroy(GcomprisUser *user);
/* List of Gcomprisusers */
void gc_profile_set_current_user(GcomprisUser *user);
diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c
index 15af359..7a73533 100644
--- a/src/gcompris/properties.c
+++ b/src/gcompris/properties.c
@@ -97,16 +97,17 @@ gc_prop_user_root_directory_get ()
gchar *
gc_prop_config_file_get()
{
+ gchar *dir;
if(config_file)
return(config_file);
-
+ dir = gc_prop_user_root_directory_get();
/* Was never called, must calculate it */
if (g_get_home_dir()==NULL) {
- config_file = g_strconcat(gc_prop_user_root_directory_get(), "/gcompris.cfg", NULL);
+ config_file = g_strconcat(dir, "/gcompris.cfg", NULL);
} else {
- config_file = g_strconcat(gc_prop_user_root_directory_get(), "/gcompris.conf", NULL);
+ config_file = g_strconcat(dir, "/gcompris.conf", NULL);
}
-
+ g_free(dir);
return(config_file);
}
@@ -197,6 +198,8 @@ gc_prop_new ()
gc_util_create_rootdir(full_rootdir);
g_free(full_rootdir);
+ g_free(user_dir);
+
g_warning("config_file %s", config_file);
filefd = open(config_file, O_RDONLY);
@@ -213,8 +216,8 @@ gc_prop_new ()
while(g_scanner_peek_next_token(scanner) != G_TOKEN_EOF) {
/* get the next token */
- GTokenType token = g_scanner_get_next_token(scanner);
- switch(token) {
+ GTokenType tokent = g_scanner_get_next_token(scanner);
+ switch(tokent) {
case G_TOKEN_IDENTIFIER: {
gchar *token;
/* if we have a symbol, check it's ours */
@@ -269,6 +272,7 @@ gc_prop_new ()
if(!tmp->database)
g_warning("Config file parsing error on token %s", token);
}
+ g_free(token);
break;
}
default:
@@ -316,10 +320,25 @@ gc_prop_new ()
void
gc_prop_destroy (GcomprisProperties *props)
{
- if(props->locale!=NULL)
- g_free(props->locale);
-
- free (props);
+ g_free(props->user_data_dir);
+ g_free(props->package_data_dir);
+ g_free(props->package_locale_dir);
+ g_free(props->package_plugin_dir);
+ g_free(props->package_python_plugin_dir);
+ g_free(props->system_icon_dir);
+ g_free(props->cache_dir);
+ g_free(props->locale);
+ g_free(props->skin);
+ g_free(props->key);
+ gc_profile_destroy(props->profile);
+ gc_user_destroy(props->logged_user);
+ g_free(props->database);
+ g_free(props->shared_dir);
+ g_free(props->users_dir);
+ g_free(props->menu_position);
+ g_free(props->server);
+ g_free (props);
+ g_warning("properties free");
}
void
diff --git a/src/gcompris/skin.c b/src/gcompris/skin.c
index eddc680..11dcb0a 100644
--- a/src/gcompris/skin.c
+++ b/src/gcompris/skin.c
@@ -330,6 +330,7 @@ skin_xml_load (gchar* skin)
if((key!=NULL)&&(data!=NULL)){
int number = atoi(data);
g_hash_table_insert(gc_skin_numbers, key, GUINT_TO_POINTER(number));
+ g_free(data);
} else {
if(key!=NULL) g_free(key);
if(data!=NULL) g_free(data);