summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFran├žois Revel <mmu_man@netsurf-browser.org>2008-11-29 22:55:56 +0000
committerFran├žois Revel <mmu_man@netsurf-browser.org>2008-11-29 22:55:56 +0000
commit50e64e8710e3af657ad97053e16435c284dc80e2 (patch)
treead2ce27279bcec54352257362197d5bc66cfb56b
parentcfad5e411a897bd30bf9f6014e58a25f1ecb69da (diff)
downloadlibparserutils-50e64e8710e3af657ad97053e16435c284dc80e2.tar.gz
libparserutils-50e64e8710e3af657ad97053e16435c284dc80e2.tar.bz2
C89
svn path=/trunk/libparserutils/; revision=5838
-rw-r--r--src/utils/buffer.c6
-rw-r--r--src/utils/dict.c11
-rw-r--r--src/utils/rbtree.c6
-rw-r--r--src/utils/stack.c4
-rw-r--r--src/utils/vector.c4
5 files changed, 23 insertions, 8 deletions
diff --git a/src/utils/buffer.c b/src/utils/buffer.c
index a7ee7f4..fcaf5d5 100644
--- a/src/utils/buffer.c
+++ b/src/utils/buffer.c
@@ -168,11 +168,15 @@ parserutils_error parserutils_buffer_grow(parserutils_buffer *buffer)
parserutils_error parserutils_buffer_randomise(parserutils_buffer *buffer)
{
+#ifndef NDEBUG
+ uint8_t *temp;
+#endif
+
if (buffer == NULL)
return PARSERUTILS_BADPARM;
#ifndef NDEBUG
- uint8_t *temp = buffer->alloc(NULL, buffer->allocated, buffer->pw);
+ temp = buffer->alloc(NULL, buffer->allocated, buffer->pw);
if (temp == NULL)
return PARSERUTILS_NOMEM;
diff --git a/src/utils/dict.c b/src/utils/dict.c
index 303389c..151e510 100644
--- a/src/utils/dict.c
+++ b/src/utils/dict.c
@@ -66,10 +66,11 @@ parserutils_error parserutils_dict_create(parserutils_alloc alloc, void *pw,
*/
parserutils_error parserutils_dict_destroy(parserutils_dict *dict)
{
+ int i;
if (dict == NULL)
return PARSERUTILS_BADPARM;
- for (int i = 0; i < TABLE_SIZE; i++) {
+ for (i = 0; i < TABLE_SIZE; i++) {
parserutils_rbtree_destroy(dict->table[i], dict_del, dict);
}
@@ -101,7 +102,9 @@ parserutils_error parserutils_dict_insert(parserutils_dict *dict,
index = dict_hash(data, len) % TABLE_SIZE;
if (dict->table[index] != NULL) {
- parserutils_dict_entry search = { len, (uint8_t *) data };
+ parserutils_dict_entry search;
+ search.len = len;
+ search.data = (uint8_t *) data;
error = parserutils_rbtree_find(dict->table[index],
(void *) &search, (void *) &entry);
@@ -263,10 +266,12 @@ static void dict_print(const void *key, const void *value, int depth)
*/
void parserutils_dict_dump(parserutils_dict *dict)
{
+ int i;
+
if (dict == NULL)
return;
- for (int i = 0; i < TABLE_SIZE; i++) {
+ for (i = 0; i < TABLE_SIZE; i++) {
printf("%d:\n", i);
parserutils_rbtree_dump(dict->table[i], dict_print);
}
diff --git a/src/utils/rbtree.c b/src/utils/rbtree.c
index 4f2b64b..4fd3c23 100644
--- a/src/utils/rbtree.c
+++ b/src/utils/rbtree.c
@@ -267,6 +267,7 @@ parserutils_error parserutils_rbtree_delete(parserutils_rbtree *tree,
rbnode *rbtree_insert_internal(parserutils_rbtree *tree, rbnode *current,
void *key, void *value, void **oldvalue)
{
+ int cmp;
if (current == NULL) {
rbnode *node = rbnode_create(tree->alloc, tree->pw, key, value);
if (node == NULL)
@@ -281,7 +282,7 @@ rbnode *rbtree_insert_internal(parserutils_rbtree *tree, rbnode *current,
if (isRed(current->left) && isRed(current->right))
colourFlip(current);
- int cmp = tree->cmp(key, current->key);
+ cmp = tree->cmp(key, current->key);
if (cmp == 0) {
*oldvalue = current->value;
@@ -355,10 +356,11 @@ rbnode *rbtree_delete_internal(parserutils_rbtree *tree, rbnode *current,
/* Must recalculate here, as current may have changed */
if (tree->cmp(key, current->key) == 0) {
+ rbnode *successor;
*intkey = current->key;
*value = current->value;
- rbnode *successor = findMin(current->right);
+ successor = findMin(current->right);
current->value = successor->value;
current->key = successor->key;
diff --git a/src/utils/stack.c b/src/utils/stack.c
index cee43ee..a157597 100644
--- a/src/utils/stack.c
+++ b/src/utils/stack.c
@@ -173,10 +173,12 @@ extern void parserutils_stack_dump(parserutils_stack *stack, const char *prefix,
void parserutils_stack_dump(parserutils_stack *stack, const char *prefix,
void (*printer)(void *item))
{
+ int32_t i;
+
if (stack == NULL || printer == NULL)
return;
- for (int32_t i = 0; i <= stack->current_item; i++) {
+ for (i = 0; i <= stack->current_item; i++) {
printf("%s %d: ", prefix != NULL ? prefix : "", i);
printer((uint8_t *) stack->items + (i * stack->item_size));
printf("\n");
diff --git a/src/utils/vector.c b/src/utils/vector.c
index f99b773..2571ba4 100644
--- a/src/utils/vector.c
+++ b/src/utils/vector.c
@@ -218,10 +218,12 @@ extern void parserutils_vector_dump(parserutils_vector *vector,
void parserutils_vector_dump(parserutils_vector *vector, const char *prefix,
void (*printer)(void *item))
{
+ int32_t i;
+
if (vector == NULL || printer == NULL)
return;
- for (int32_t i = 0; i <= vector->current_item; i++) {
+ for (i = 0; i <= vector->current_item; i++) {
printf("%s %d: ", prefix != NULL ? prefix : "", i);
printer((uint8_t *) vector->items + (i * vector->item_size));
printf("\n");