replaced glib function calls to g_list_*()
[rocksndiamonds.git] / src / game_bd / bd_caveset.c
index 26fe734b53a69ebb6ab275ab64969d010cc1b666..49b6e1003a3ce3af82d66ecc5f23d43429107531 100644 (file)
@@ -22,7 +22,7 @@
 
 
 /* this stores the caves. */
-GList *gd_caveset;
+List *gd_caveset;
 
 /* the data of the caveset: name, highscore, max number of lives, etc. */
 GdCavesetData *gd_caveset_data;
@@ -45,7 +45,7 @@ char *gd_caveset_extensions[] =
   NULL
 };
 
-#define CAVESET_OFFSET(property) (G_STRUCT_OFFSET(GdCavesetData, property))
+#define CAVESET_OFFSET(property) (STRUCT_OFFSET(GdCavesetData, property))
 
 const GdStructDescriptor gd_caveset_properties[] =
 {
@@ -84,16 +84,9 @@ static GdPropertyDefault caveset_defaults[] =
 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;
@@ -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)
-      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);
 }
@@ -122,8 +115,8 @@ void gd_caveset_clear(void)
 {
   if (gd_caveset)
   {
-    g_list_foreach(gd_caveset, (GFunc) gd_cave_free, NULL);
-    g_list_free(gd_caveset);
+    list_foreach(gd_caveset, (list_fn) gd_cave_free, NULL);
+    list_free(gd_caveset);
     gd_caveset = NULL;
   }
 
@@ -142,13 +135,13 @@ void gd_caveset_clear(void)
 /* return number of caves currently in memory. */
 int gd_caveset_count(void)
 {
-  return g_list_length(gd_caveset);
+  return list_length(gd_caveset);
 }
 
 /* return index of first selectable cave */
 static int caveset_first_selectable_cave_index(void)
 {
-  GList *iter;
+  List *iter;
   int i;
 
   for (i = 0, iter = gd_caveset; iter != NULL; i++, iter = iter->next)
@@ -168,7 +161,7 @@ static int caveset_first_selectable_cave_index(void)
 /* return a cave identified by its index */
 GdCave *gd_return_nth_cave(const int cave)
 {
-  return g_list_nth_data(gd_caveset, cave);
+  return list_nth_data(gd_caveset, cave);
 }
 
 /* get a selected cave from the loaded caveset (original, unmodified cave) */
@@ -476,7 +469,7 @@ static void brc_import(guint8 *data)
 
       /* append to caveset or forget it. */
       if (!only_dirt)
-       gd_caveset = g_list_append(gd_caveset, cave);
+       gd_caveset = list_append(gd_caveset, cave);
       else
        gd_cave_free(cave);
     }
@@ -515,7 +508,7 @@ boolean gd_caveset_load_from_file(char *filename)
   gsize length;
   char *buf;
   boolean read;
-  GList *new_caveset;
+  List *new_caveset;
   struct stat st;
 
   if (g_stat(filename, &st) != 0)
@@ -613,7 +606,7 @@ boolean gd_caveset_load_from_file(char *filename)
 
 int gd_cave_check_replays(GdCave *cave, boolean report, boolean remove, boolean repair)
 {
-  GList *riter;
+  List *riter;
   int wrong = 0;
 
   riter = cave->replays;
@@ -622,7 +615,7 @@ int gd_cave_check_replays(GdCave *cave, boolean report, boolean remove, boolean
     GdReplay *replay = (GdReplay *)riter->data;
     guint32 checksum;
     GdCave *rendered;
-    GList *next = riter->next;
+    List *next = riter->next;
 
     rendered = gd_cave_new_rendered(cave, replay->level, replay->seed);
     checksum = gd_cave_adler_checksum(rendered);
@@ -653,7 +646,7 @@ int gd_cave_check_replays(GdCave *cave, boolean report, boolean remove, boolean
        if (remove)
        {
          /* may remove */
-         cave->replays = g_list_remove_link(cave->replays, riter);
+         cave->replays = list_remove_link(cave->replays, riter);
          gd_replay_free(replay);
        }
       }
@@ -668,7 +661,7 @@ int gd_cave_check_replays(GdCave *cave, boolean report, boolean remove, boolean
 
 boolean gd_caveset_has_replays(void)
 {
-  GList *citer;
+  List *citer;
 
   /* for all caves */
   for (citer = gd_caveset; citer != NULL; citer = citer->next)