projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d2b7c54
)
replaced glib function calls to g_string_*()
author
Holger Schemel
<info@artsoft.org>
Tue, 20 Feb 2024 01:13:48 +0000
(
02:13
+0100)
committer
Holger Schemel
<info@artsoft.org>
Tue, 20 Feb 2024 01:14:37 +0000
(
02:14
+0100)
src/game_bd/bd_bdcff.c
patch
|
blob
|
history
src/game_bd/bd_cave.c
patch
|
blob
|
history
src/game_bd/bd_cave.h
patch
|
blob
|
history
src/game_bd/bd_caveset.c
patch
|
blob
|
history
src/game_bd/bd_caveset.h
patch
|
blob
|
history
src/game_bd/bd_gameplay.c
patch
|
blob
|
history
diff --git
a/src/game_bd/bd_bdcff.c
b/src/game_bd/bd_bdcff.c
index 490dc1afbe43bf27dd608cb84b1aded6eb6ebd61..06e5e06ba2ae607c43ff4852e18c682db76e31c1 100644
(file)
--- a/
src/game_bd/bd_bdcff.c
+++ b/
src/game_bd/bd_bdcff.c
@@
-188,12
+188,10
@@
static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_
if (prop_desc[i].type == GD_TYPE_LONGSTRING)
{
if (prop_desc[i].type == GD_TYPE_LONGSTRING)
{
- GString *str = *(GString **)value;
- char *compressed;
+ char **str = (char **)value;
- compressed = getUnescapedString(param);
- g_string_assign(str, compressed);
- free(compressed);
+ checked_free(*str);
+ *str = getUnescapedString(param);
/* remember this to skip checking the number of parameters at the end of the function */
was_string = TRUE;
/* remember this to skip checking the number of parameters at the end of the function */
was_string = TRUE;
diff --git
a/src/game_bd/bd_cave.c
b/src/game_bd/bd_cave.c
index 86b07a889bee26e1a36866053f22b8e78b1e8df3..b0f1573ef52d96992e70bb6aa6cccdc1680ec9cc 100644
(file)
--- a/
src/game_bd/bd_cave.c
+++ b/
src/game_bd/bd_cave.c
@@
-443,7
+443,6
@@
guint gd_str_case_hash(gconstpointer v)
*/
GdCave *gd_cave_new(void)
{
*/
GdCave *gd_cave_new(void)
{
- int i;
GdCave *cave;
cave = checked_calloc(sizeof(GdCave));
GdCave *cave;
cave = checked_calloc(sizeof(GdCave));
@@
-451,11
+450,6
@@
GdCave *gd_cave_new(void)
/* hash table which stores unknown tags as strings. */
cave->tags = g_hash_table_new_full(gd_str_case_hash, gd_str_case_equal, free, free);
/* hash table which stores unknown tags as strings. */
cave->tags = g_hash_table_new_full(gd_str_case_hash, gd_str_case_equal, free, free);
- /* for strings */
- for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
- if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
- G_STRUCT_MEMBER(GString *, cave, gd_cave_properties[i].offset) = g_string_new(NULL);
-
gd_cave_set_gdash_defaults(cave);
return cave;
gd_cave_set_gdash_defaults(cave);
return cave;
@@
-546,10
+540,10
@@
void gd_cave_free(GdCave *cave)
if (cave->random) /* random generator is a GRand * */
g_rand_free(cave->random);
if (cave->random) /* random generator is a GRand * */
g_rand_free(cave->random);
- /* free
GS
trings */
+ /* free
s
trings */
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
-
g_string_free(G_STRUCT_MEMBER(GString *, cave, gd_cave_properties[i].offset), TRUE
);
+
checked_free(G_STRUCT_MEMBER(char *, cave, gd_cave_properties[i].offset)
);
/* map */
gd_cave_map_free(cave->map);
/* map */
gd_cave_map_free(cave->map);
@@
-597,8
+591,8
@@
void gd_cave_copy(GdCave *dest, const GdCave *src)
/* for longstrings */
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
/* for longstrings */
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
- G_STRUCT_MEMBER(
GString
*, dest, gd_cave_properties[i].offset) =
- g
_string_new(G_STRUCT_MEMBER(GString *, src, gd_cave_properties[i].offset)->str
);
+ G_STRUCT_MEMBER(
char
*, dest, gd_cave_properties[i].offset) =
+ g
etStringCopy(G_STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset)
);
/* no reason to copy this */
dest->objects_order = NULL;
/* no reason to copy this */
dest->objects_order = NULL;
@@
-1396,8
+1390,6
@@
GdReplay *gd_replay_new(void)
rep = checked_calloc(sizeof(GdReplay));
rep = checked_calloc(sizeof(GdReplay));
- /* create dynamic objects */
- rep->comment = g_string_new(NULL);
rep->movements = g_byte_array_new();
return rep;
rep->movements = g_byte_array_new();
return rep;
@@
-1410,7
+1402,7
@@
GdReplay *gd_replay_new_from_replay(GdReplay *orig)
rep = g_memdup(orig, sizeof(GdReplay));
/* replicate dynamic data */
rep = g_memdup(orig, sizeof(GdReplay));
/* replicate dynamic data */
- rep->comment = g
_string_new(orig->comment->str
);
+ rep->comment = g
etStringCopy(orig->comment
);
rep->movements = g_byte_array_new();
g_byte_array_append(rep->movements, orig->movements->data, orig->movements->len);
rep->movements = g_byte_array_new();
g_byte_array_append(rep->movements, orig->movements->data, orig->movements->len);
@@
-1420,7
+1412,7
@@
GdReplay *gd_replay_new_from_replay(GdReplay *orig)
void gd_replay_free(GdReplay *replay)
{
g_byte_array_free(replay->movements, TRUE);
void gd_replay_free(GdReplay *replay)
{
g_byte_array_free(replay->movements, TRUE);
-
g_string_free(replay->comment, TRUE
);
+
checked_free(replay->comment
);
free(replay);
}
free(replay);
}
diff --git
a/src/game_bd/bd_cave.h
b/src/game_bd/bd_cave.h
index aa27a5f73604efe438a7913dcb3947f824d40966..bd677ead2280668ff791dc6cfd72039a13cc9888 100644
(file)
--- a/
src/game_bd/bd_cave.h
+++ b/
src/game_bd/bd_cave.h
@@
-322,7
+322,7
@@
typedef struct _gd_cave_replay
GdString player_name; /* who played this */
GdString date; /* when played */
GdString player_name; /* who played this */
GdString date; /* when played */
-
GString *comment;
/* some comments from the player */
+
char *comment;
/* some comments from the player */
int score; /* score collected */
int duration; /* number of seconds played */
int score; /* score collected */
int duration; /* number of seconds played */
@@
-366,8
+366,8
@@
typedef struct _gd_cave
GdString difficulty; /* difficulty of the game, for info purposes */
GdString www; /* link to author's webpage */
GdString date; /* date of creation */
GdString difficulty; /* difficulty of the game, for info purposes */
GdString www; /* link to author's webpage */
GdString date; /* date of creation */
-
GString *story;
/* story for the cave - will be shown when the cave is played. */
-
GString *remark;
/* some note */
+
char *story;
/* story for the cave - will be shown when the cave is played. */
+
char *remark;
/* some note */
GdString charset; /* these are not used by gdash */
GdString fontset;
GdString charset; /* these are not used by gdash */
GdString fontset;
diff --git
a/src/game_bd/bd_caveset.c
b/src/game_bd/bd_caveset.c
index 26fe734b53a69ebb6ab275ab64969d010cc1b666..e25fa6263a70c2acdfdec691d5afc1bf80839013 100644
(file)
--- a/
src/game_bd/bd_caveset.c
+++ b/
src/game_bd/bd_caveset.c
@@
-84,16
+84,9
@@
static GdPropertyDefault caveset_defaults[] =
GdCavesetData *gd_caveset_data_new(void)
{
GdCavesetData *data;
GdCavesetData *gd_caveset_data_new(void)
{
GdCavesetData *data;
- int i;
data = checked_calloc(sizeof(GdCavesetData));
data = checked_calloc(sizeof(GdCavesetData));
- /* create strings */
- for (i = 0; gd_caveset_properties[i].identifier != NULL; i++)
- if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING)
- G_STRUCT_MEMBER(GString *, data, gd_caveset_properties[i].offset) =
- g_string_new(NULL);
-
gd_struct_set_defaults_from_array(data, gd_caveset_properties, caveset_defaults);
return data;
gd_struct_set_defaults_from_array(data, gd_caveset_properties, caveset_defaults);
return data;
@@
-106,7
+99,7
@@
void gd_caveset_data_free(GdCavesetData *data)
/* free strings */
for (i = 0; gd_caveset_properties[i].identifier != NULL; i++)
if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING)
/* free strings */
for (i = 0; gd_caveset_properties[i].identifier != NULL; i++)
if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING)
-
g_string_free(G_STRUCT_MEMBER(GString *, data, gd_caveset_properties[i].offset), TRUE
);
+
checked_free(G_STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset)
);
free(data);
}
free(data);
}
diff --git
a/src/game_bd/bd_caveset.h
b/src/game_bd/bd_caveset.h
index 94ec437862365bdf21a5334ed675c02c837e9baf..e5a5a7e6a85bb27abeb0aa04952b42876f15f36d 100644
(file)
--- a/
src/game_bd/bd_caveset.h
+++ b/
src/game_bd/bd_caveset.h
@@
-31,11
+31,11
@@
typedef struct _gd_caveset_data
GdString www; /* link to author's webpage */
GdString date; /* date of creation */
GdString www; /* link to author's webpage */
GdString date; /* date of creation */
-
GString *story;
/* story for the caves */
-
GString *remark;
/* notes about the game */
+
char *story;
/* story for the caves */
+
char *remark;
/* notes about the game */
-
GString *title_screen;
/* base64-encoded title screen image */
-
GString *title_screen_scroll;
/* scrolling background for title screen image */
+
char *title_screen;
/* base64-encoded title screen image */
+
char *title_screen_scroll;
/* scrolling background for title screen image */
GdString charset; /* these are not used by gdash */
GdString fontset;
GdString charset; /* these are not used by gdash */
GdString fontset;
diff --git
a/src/game_bd/bd_gameplay.c
b/src/game_bd/bd_gameplay.c
index ffedad2cb4e093e492191c397ffa65011ab2cdd3..ec757454f4f125945fb27e86a1d6bf9c6900bf9a 100644
(file)
--- a/
src/game_bd/bd_gameplay.c
+++ b/
src/game_bd/bd_gameplay.c
@@
-397,8
+397,8
@@
static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean
/* if we have a story... */
#if 0
/* if we have a story... */
#if 0
- if (game->show_story && game->original_cave && game->original_cave->story
->len != 0
)
- Info("Cave Story: %s", game->original_cave->story
->str
);
+ if (game->show_story && game->original_cave && game->original_cave->story
!= NULL
)
+ Info("Cave Story: %s", game->original_cave->story);
#endif
counter_next = GAME_INT_START_UNCOVER;
#endif
counter_next = GAME_INT_START_UNCOVER;