Added global class initialization automation

Finalized basics of plugin loading
Began redoing how dependencies will be tracked
Renamed some bad names
Finished some stuff in ForwardSys

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40216
This commit is contained in:
David Anderson
2006-12-15 13:38:04 +00:00
parent a93faa3cbf
commit 90d1f4495e
16 changed files with 509 additions and 131 deletions
+50
View File
@@ -266,6 +266,56 @@ void sm_trie_destroy(Trie *trie)
delete trie;
}
bool sm_trie_delete(Trie *trie, const char *key)
{
unsigned int lastidx = 1; /* the last node index */
unsigned int curidx; /* current node index */
const char *keyptr = key; /* input stream at current token */
TrieNode *node = NULL; /* current node being processed */
TrieNode *base = trie->base;
if (!*key)
{
return false;
}
/* Start traversing at the root node */
do
{
/* Find where the next character is, then advance */
curidx = base[lastidx].idx;
node = &base[curidx];
curidx += charval(*keyptr);
node = &base[curidx];
keyptr++;
/* Check if this slot is supposed to be empty or is a collision */
if ((curidx > trie->baseSize) || node->mode == Node_Unused || node->parent != lastidx)
{
return false;
} else if (node->mode == Node_Term) {
char *term = &trie->stringtab[node->idx];
if (strcmp(keyptr, term) == 0)
{
break;
}
}
lastidx = curidx;
} while (*keyptr != '\0');
assert(node != NULL);
if (!node->valset)
{
return false;
}
node->valset = false;
node->value = NULL;
return true;
}
bool sm_trie_retrieve(Trie *trie, const char *key, void **value)
{
unsigned int lastidx = 1; /* the last node index */