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;
*/
GdCave *gd_cave_new(void)
{
- int i;
GdCave *cave;
cave = checked_calloc(sizeof(GdCave));
/* 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;
if (cave->random) /* random generator is a GRand * */
g_rand_free(cave->random);
- /* free GStrings */
+ /* free strings */
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);
/* 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) =
+ getStringCopy(G_STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset));
/* no reason to copy this */
dest->objects_order = NULL;
rep = checked_calloc(sizeof(GdReplay));
- /* create dynamic objects */
- rep->comment = g_string_new(NULL);
rep->movements = g_byte_array_new();
return rep;
rep = g_memdup(orig, sizeof(GdReplay));
/* replicate dynamic data */
- rep->comment = g_string_new(orig->comment->str);
+ rep->comment = getStringCopy(orig->comment);
rep->movements = g_byte_array_new();
g_byte_array_append(rep->movements, orig->movements->data, orig->movements->len);
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);
}
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 */
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;
GdCavesetData *gd_caveset_data_new(void)
{
GdCavesetData *data;
- int i;
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;
/* 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);
}
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;
/* 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;