projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added preliminary Symbian support.
[silc.git]
/
lib
/
silcutil
/
tests
/
test_silchashtable.c
diff --git
a/lib/silcutil/tests/test_silchashtable.c
b/lib/silcutil/tests/test_silchashtable.c
index 47326c0db6cbc83cd057654c3cfa7a5298e5d396..622fc4536647868c726adb791e0799f938224734 100644
(file)
--- a/
lib/silcutil/tests/test_silchashtable.c
+++ b/
lib/silcutil/tests/test_silchashtable.c
@@
-1,14
+1,14
@@
/* Hash table tests */
/* Hash table tests */
-#include "silc
includes
.h"
+#include "silc.h"
typedef struct entry_struct {
char name[8];
int val;
} *entry;
typedef struct entry_struct {
char name[8];
int val;
} *entry;
-
b
ool dump = FALSE;
-
b
ool auto_rehash = TRUE;
+
SilcB
ool dump = FALSE;
+
SilcB
ool auto_rehash = TRUE;
int count = 2000;
SilcHashTable t = NULL;
int count = 2000;
SilcHashTable t = NULL;
@@
-18,7
+18,7
@@
SilcUInt32 hash_entry(void *key, void *user_context)
return e->val + silc_hash_string(e->name, NULL);
}
return e->val + silc_hash_string(e->name, NULL);
}
-
b
ool hash_compare(void *key1, void *key2, void *user_context)
+
SilcB
ool hash_compare(void *key1, void *key2, void *user_context)
{
entry e = key1;
entry e2 = key2;
{
entry e = key1;
entry e2 = key2;
@@
-38,7
+38,7
@@
void hash_destructor(void *key, void *context, void *user_context)
silc_free(e);
}
silc_free(e);
}
-
b
ool add_entries()
+
SilcB
ool add_entries()
{
entry e;
int i;
{
entry e;
int i;
@@
-49,7
+49,7
@@
bool add_entries()
e = silc_calloc(1, sizeof(*e));
if (!e)
return FALSE;
e = silc_calloc(1, sizeof(*e));
if (!e)
return FALSE;
- snprintf(e->name, sizeof(e->name), "%d", i);
+ s
ilc_s
nprintf(e->name, sizeof(e->name), "%d", i);
e->val = i;
silc_hash_table_add(t, (void *)e, (void *)e->name);
e->val = i;
silc_hash_table_add(t, (void *)e, (void *)e->name);
@@
-60,7
+60,7
@@
bool add_entries()
return TRUE;
}
return TRUE;
}
-
b
ool del_entries_with_list()
+
SilcB
ool del_entries_with_list()
{
SilcHashTableList htl;
entry e;
{
SilcHashTableList htl;
entry e;
@@
-90,7
+90,7
@@
void del_foreach(void *key, void *context, void *user_context)
silc_hash_table_del(t, key);
}
silc_hash_table_del(t, key);
}
-
b
ool del_n_entries_foreach()
+
SilcB
ool del_n_entries_foreach()
{
struct entry_struct f;
int i;
{
struct entry_struct f;
int i;
@@
-99,7
+99,7
@@
bool del_n_entries_foreach()
for (i = 0; i < count; i++) {
memset(&f, 0, sizeof(f));
for (i = 0; i < count; i++) {
memset(&f, 0, sizeof(f));
- snprintf(f.name, sizeof(f.name), "%d", i);
+ s
ilc_s
nprintf(f.name, sizeof(f.name), "%d", i);
f.val = i;
silc_hash_table_find_foreach(t, &f, del_foreach, NULL);
f.val = i;
silc_hash_table_find_foreach(t, &f, del_foreach, NULL);
@@
-108,14
+108,14
@@
bool del_n_entries_foreach()
return TRUE;
}
return TRUE;
}
-
b
ool del_entries_foreach()
+
SilcB
ool del_entries_foreach()
{
SILC_LOG_DEBUG(("Deleting all entries with foreach"));
silc_hash_table_foreach(t, del_foreach, NULL);
return TRUE;
}
{
SILC_LOG_DEBUG(("Deleting all entries with foreach"));
silc_hash_table_foreach(t, del_foreach, NULL);
return TRUE;
}
-
b
ool alloc_table()
+
SilcB
ool alloc_table()
{
SILC_LOG_DEBUG(("Allocating hash table with %d entries (%s)",
count, auto_rehash ? "auto rehash" : "no auto rehash"));
{
SILC_LOG_DEBUG(("Allocating hash table with %d entries (%s)",
count, auto_rehash ? "auto rehash" : "no auto rehash"));
@@
-137,7
+137,7
@@
bool alloc_table()
return TRUE;
}
return TRUE;
}
-
b
ool delete_table_with_list()
+
SilcB
ool delete_table_with_list()
{
SILC_LOG_DEBUG(("Deleting entries with SilcHashTableList"));
{
SILC_LOG_DEBUG(("Deleting entries with SilcHashTableList"));
@@
-158,7
+158,7
@@
bool delete_table_with_list()
return TRUE;
}
return TRUE;
}
-
b
ool find_entries()
+
SilcB
ool find_entries()
{
struct entry_struct f;
entry e;
{
struct entry_struct f;
entry e;
@@
-169,7
+169,7
@@
bool find_entries()
for (i = 0; i < count; i++) {
memset(&f, 0, sizeof(f));
for (i = 0; i < count; i++) {
memset(&f, 0, sizeof(f));
- snprintf(f.name, sizeof(f.name), "%d", i);
+ s
ilc_s
nprintf(f.name, sizeof(f.name), "%d", i);
f.val = i;
/* Find */
f.val = i;
/* Find */
@@
-184,12
+184,12
@@
bool find_entries()
return TRUE;
}
return TRUE;
}
-
b
ool dump_table()
+
SilcB
ool dump_table()
{
SilcHashTableList htl;
entry e;
char *name;
{
SilcHashTableList htl;
entry e;
char *name;
-
b
ool dumpped = FALSE;
+
SilcB
ool dumpped = FALSE;
SILC_LOG_DEBUG(("Dumping hash table entries"));
SILC_LOG_DEBUG(("Dumping hash table entries"));
@@
-207,17
+207,18
@@
bool dump_table()
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
-
b
ool success = FALSE;
+
SilcB
ool success = FALSE;
int i;
if (argc > 1 && !strcmp(argv[1], "-d")) {
int i;
if (argc > 1 && !strcmp(argv[1], "-d")) {
- silc_debug = 1;
- silc_debug_hexdump = 1;
+ silc_log_debug(TRUE);
+ silc_log_debug_hexdump(TRUE);
+ silc_log_quick(TRUE);
silc_log_set_debug_string("*table*");
}
if (argc > 1 && !strcmp(argv[1], "-D")) {
silc_log_set_debug_string("*table*");
}
if (argc > 1 && !strcmp(argv[1], "-D")) {
- silc_
debug = 1
;
+ silc_
log_debug(TRUE)
;
dump = TRUE;
silc_log_set_debug_string("*table*");
}
dump = TRUE;
silc_log_set_debug_string("*table*");
}
@@
-246,7
+247,7
@@
int main(int argc, char **argv)
auto_rehash = TRUE;
if (!alloc_table())
goto err;
auto_rehash = TRUE;
if (!alloc_table())
goto err;
- count =
3
999;
+ count =
17
999;
if (!add_entries())
goto err;
SILC_LOG_DEBUG(("rehash"));
if (!add_entries())
goto err;
SILC_LOG_DEBUG(("rehash"));