diff src/xs_stil.c @ 751:55eea3fa8868

Rename some structures.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 05 Nov 2012 18:42:57 +0200
parents 9321ffa2ea7e
children 64352e85113e
line wrap: on
line diff
--- a/src/xs_stil.c	Mon Nov 05 17:53:22 2012 +0200
+++ b/src/xs_stil.c	Mon Nov 05 18:42:57 2012 +0200
@@ -30,7 +30,7 @@
 
 /* Database handling functions
  */
-static gboolean xs_stildb_node_realloc(stil_node_t *node, gint nsubTunes)
+static gboolean xs_stildb_node_realloc(XSSTILNode *node, gint nsubTunes)
 {
     if (!node) return FALSE;
 
@@ -39,8 +39,8 @@
         gint clearIndex, clearLength;
         
         node->subTunes =
-            (stil_subnode_t **) g_realloc(node->subTunes,
-            (nsubTunes + 1) * sizeof(stil_subnode_t **));
+            (XSSTILSubNode **) g_realloc(node->subTunes,
+            (nsubTunes + 1) * sizeof(XSSTILSubNode **));
 
         if (!node->subTunes) {
             xs_error("SubTune pointer structure realloc failed.\n");
@@ -55,15 +55,15 @@
             clearIndex = node->nsubTunes + 1;
             clearLength = (nsubTunes - clearIndex + 1);
         }
-        memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **));
+        memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(XSSTILSubNode **));
         
         node->nsubTunes = nsubTunes;
     }
 
     /* Allocate memory for subTune */
     if (!node->subTunes[nsubTunes]) {
-        node->subTunes[nsubTunes] = (stil_subnode_t *)
-            g_malloc0(sizeof(stil_subnode_t));
+        node->subTunes[nsubTunes] = (XSSTILSubNode *)
+            g_malloc0(sizeof(XSSTILSubNode));
         
         if (!node->subTunes[nsubTunes]) {
             xs_error("SubTune structure malloc failed!\n");
@@ -75,10 +75,10 @@
 }
 
 
-static void xs_stildb_node_free(stil_node_t *node)
+static void xs_stildb_node_free(XSSTILNode *node)
 {
     gint i;
-    stil_subnode_t *subnode;
+    XSSTILSubNode *subnode;
 
     if (!node) return;
 
@@ -99,12 +99,12 @@
 }
 
 
-static stil_node_t *xs_stildb_node_new(gchar *filename)
+static XSSTILNode *xs_stildb_node_new(gchar *filename)
 {
-    stil_node_t *result;
+    XSSTILNode *result;
 
     /* Allocate memory for new node */
-    result = (stil_node_t *) g_malloc0(sizeof(stil_node_t));
+    result = (XSSTILNode *) g_malloc0(sizeof(XSSTILNode));
     if (!result)
         return NULL;
 
@@ -121,7 +121,7 @@
 
 /* Insert given node to db linked list
  */
-static void xs_stildb_node_insert(xs_stildb_t *db, stil_node_t *node)
+static void xs_stildb_node_insert(XSSTILDB *db, XSSTILNode *node)
 {
     assert(db != NULL);
 
@@ -158,12 +158,12 @@
     fprintf(stderr, "#%d: '%s'\n", lineNum, inLine);
 }
 
-gint xs_stildb_read(xs_stildb_t *db, gchar *dbFilename)
+gint xs_stildb_read(XSSTILDB *db, gchar *dbFilename)
 {
     FILE *inFile;
     gchar inLine[XS_BUF_SIZE + 16];    /* Since we add some chars here and there */
     size_t lineNum;
-    stil_node_t *tmnode;
+    XSSTILNode *tmnode;
     gboolean isError, isMulti;
     gint subEntry;
     gchar *tmpLine = inLine;
@@ -330,16 +330,16 @@
 {
     /* We assume here that we never ever get NULL-pointers or similar */
     return strcmp(
-        (*(stil_node_t **) node1)->filename,
-        (*(stil_node_t **) node2)->filename);
+        (*(XSSTILNode **) node1)->filename,
+        (*(XSSTILNode **) node2)->filename);
 }
 
 
 /* (Re)create index
  */
-gint xs_stildb_index(xs_stildb_t *db)
+gint xs_stildb_index(XSSTILDB *db)
 {
-    stil_node_t *curr;
+    XSSTILNode *curr;
     size_t i;
 
     /* Free old index */
@@ -359,7 +359,7 @@
     /* Check number of nodes */
     if (db->n > 0) {
         /* Allocate memory for index-table */
-        db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n);
+        db->pindex = (XSSTILNode **) g_malloc(sizeof(XSSTILNode *) * db->n);
         if (!db->pindex)
             return -1;
 
@@ -372,7 +372,7 @@
         }
 
         /* Sort the indexes */
-        qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
+        qsort(db->pindex, db->n, sizeof(XSSTILNode *), xs_stildb_cmp);
     }
 
     return 0;
@@ -381,9 +381,9 @@
 
 /* Free a given STIL database
  */
-void xs_stildb_free(xs_stildb_t *db)
+void xs_stildb_free(XSSTILDB *db)
 {
-    stil_node_t *curr, *next;
+    XSSTILNode *curr, *next;
 
     if (!db)
         return;
@@ -412,9 +412,9 @@
 
 /* Get STIL information node from database
  */
-stil_node_t *xs_stildb_get_node(xs_stildb_t *db, gchar *filename)
+XSSTILNode *xs_stildb_get_node(XSSTILDB *db, gchar *filename)
 {
-    stil_node_t keyItem, *key, **item;
+    XSSTILNode keyItem, *key, **item;
 
     /* Check the database pointers */
     if (!db || !db->nodes || !db->pindex)
@@ -423,7 +423,7 @@
     /* Look-up index using binary search */
     keyItem.filename = filename;
     key = &keyItem;
-    item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
+    item = bsearch(&key, db->pindex, db->n, sizeof(XSSTILNode *), xs_stildb_cmp);
     if (item)
         return *item;
     else