# HG changeset patch # User Matti Hamalainen # Date 1073775241 0 # Node ID 3898d4fdbd49881f404f77e439a944f7c8853d97 # Parent 4e929bb71057862bf6b2291f6cd19aeacee1963b Renamed some variables diff -r 4e929bb71057 -r 3898d4fdbd49 src/xs_length.c --- a/src/xs_length.c Sat Jan 10 22:53:04 2004 +0000 +++ b/src/xs_length.c Sat Jan 10 22:54:01 2004 +0000 @@ -31,9 +31,9 @@ /* * Pointer to database in memory */ -static t_xs_sldb_node *xs_database = NULL; -static t_xs_sldb_node **xs_dbindex = NULL; -static gint xs_dbnodes = 0; +static t_xs_sldb_node *xs_sldb = NULL; +static t_xs_sldb_node **xs_sldbi = NULL; +static gint xs_sldbn = 0; /* @@ -66,15 +66,15 @@ void xs_db_node_insert(t_xs_sldb_node *pNode) { - if (xs_database) + if (xs_sldb) { /* The first node's pPrev points to last node */ - LPREV = xs_database->pPrev; /* New node's prev = Previous last node */ - xs_database->pPrev->pNext = pNode; /* Previous last node's next = New node */ - xs_database->pPrev = pNode; /* New last node = New node */ + LPREV = xs_sldb->pPrev; /* New node's prev = Previous last node */ + xs_sldb->pPrev->pNext = pNode; /* Previous last node's next = New node */ + xs_sldb->pPrev = pNode; /* New last node = New node */ LNEXT = NULL; /* But next is NULL! */ } else { - xs_database = pNode; /* First node ... */ + xs_sldb = pNode; /* First node ... */ LPREV = pNode; /* ... it's also last */ LNEXT = NULL; /* But next is NULL! */ } @@ -109,19 +109,19 @@ t_xs_sldb_node *pResult; /* Check the database pointers */ - if (!xs_database || !xs_dbindex) + if (!xs_sldb || !xs_sldbi) return NULL; /* Look-up via index using binary search */ pResult = NULL; iStartNode = 0; - iEndNode = (xs_dbnodes - 1); + iEndNode = (xs_sldbn - 1); iQNode = (iEndNode / 2); iFound = FALSE; while ((!iFound) && ((iEndNode - iStartNode) > 128)) { - r = xs_db_cmphash(pHash, xs_dbindex[iQNode]->md5Hash); + r = xs_db_cmphash(pHash, xs_sldbi[iQNode]->md5Hash); if (r < 0) { /* Hash was in the <- LEFT side */ @@ -145,7 +145,7 @@ i = iStartNode; while ((i <= iEndNode) && (!iFound)) { - if (xs_db_cmphash(pHash, xs_dbindex[i]->md5Hash) == 0) + if (xs_db_cmphash(pHash, xs_sldbi[i]->md5Hash) == 0) iFound = TRUE; else i++; @@ -153,11 +153,11 @@ /* Check the result */ if (iFound) - pResult = xs_dbindex[i]; + pResult = xs_sldbi[i]; } else { /* Found via binary search */ - pResult = xs_dbindex[iQNode]; + pResult = xs_sldbi[iQNode]; } @@ -345,32 +345,32 @@ XSDEBUG("indexing...\n"); /* Get size of db */ - pCurr = xs_database; - xs_dbnodes = 0; + pCurr = xs_sldb; + xs_sldbn = 0; while (pCurr) { - xs_dbnodes++; + xs_sldbn++; pCurr = pCurr->pNext; } /* Check number of nodes */ - if (xs_dbnodes > 0) + if (xs_sldbn > 0) { /* Allocate memory for index-table */ - xs_dbindex = (t_xs_sldb_node **) g_malloc(sizeof(t_xs_sldb_node *) * xs_dbnodes); - if (!xs_dbindex) return -6; + xs_sldbi = (t_xs_sldb_node **) g_malloc(sizeof(t_xs_sldb_node *) * xs_sldbn); + if (!xs_sldbi) return -6; /* Get node-pointers to table */ i = 0; - pCurr = xs_database; + pCurr = xs_sldb; while (pCurr) { - xs_dbindex[i++] = pCurr; + xs_sldbi[i++] = pCurr; pCurr = pCurr->pNext; } /* Sort the indexes */ - qsort(xs_dbindex, xs_dbnodes, sizeof(t_xs_sldb_node *), xs_db_cmp); + qsort(xs_sldbi, xs_sldbn, sizeof(t_xs_sldb_node *), xs_db_cmp); } /* OK */ @@ -388,7 +388,7 @@ /* Free the memory allocated for database */ XSDEBUG("sldb_close()\n"); - pCurr = xs_database; + pCurr = xs_sldb; while (pCurr) { pNext = pCurr->pNext; @@ -396,13 +396,13 @@ pCurr = pNext; } - xs_database = NULL; + xs_sldb = NULL; /* Free memory allocated for indexes */ - if (xs_dbindex) + if (xs_sldbi) { - g_free(xs_dbindex); - xs_dbindex = NULL; + g_free(xs_sldbi); + xs_sldbi = NULL; } }