* the common case (external keys) both can be used.</li>
* </ul>
*
- * \version $Id$
* \author Giovanni Bajo <rasky@develer.com>
*/
#include "hashtable.h"
+
+#include "cfg/cfg_hashtable.h"
#include <cfg/debug.h>
#include <cfg/compiler.h>
#include <cfg/macros.h> //ROTL(), ROTR();
return *node;
}
-
-
-#if 0
-
-#include <stdlib.h>
-
-bool ht_test(void);
-
-static const void* test_get_key(const void* ptr, uint8_t* length)
-{
- const char* s = ptr;
- *length = strlen(s);
- return s;
-}
-
-#define NUM_ELEMENTS 256
-DECLARE_HASHTABLE_STATIC(test1, 256, test_get_key);
-DECLARE_HASHTABLE_INTERNALKEY_STATIC(test2, 256);
-
-static char data[NUM_ELEMENTS][10];
-static char keydomain[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-static bool single_test(void)
-{
- int i;
-
- ht_init(&test1);
- ht_init(&test2);
-
- for (i=0;i<NUM_ELEMENTS;i++)
- {
- int k;
- int klen;
-
- do
- {
- klen = (rand() % 8) + 1;
- for (k=0;k<klen;k++)
- data[i][k] = keydomain[rand() % (sizeof(keydomain)-1)];
- data[i][k]=0;
- } while (ht_find_str(&test1, data[i]) != NULL);
-
- ASSERT(ht_insert(&test1, data[i]));
- ASSERT(ht_insert_str(&test2, data[i], data[i]));
- }
-
- for (i=0;i<NUM_ELEMENTS;i++)
- {
- char *found1, *found2;
-
- found1 = (char*)ht_find_str(&test1, data[i]);
- if (strcmp(found1, data[i]) != 0)
- {
- ASSERT(strcmp(found1,data[i]) == 0);
- return false;
- }
-
- found2 = (char*)ht_find_str(&test2, data[i]);
- if (strcmp(found2, data[i]) != 0)
- {
- ASSERT(strcmp(found2,data[i]) == 0);
- return false;
- }
- }
-
- return true;
-}
-
-static uint16_t rand_seeds[] = { 1, 42, 666, 0xDEAD, 0xBEEF, 0x1337, 0xB00B };
-
-bool ht_test(void)
-{
- int i;
-
- for (i=0;i<countof(rand_seeds);++i)
- {
- srand(rand_seeds[i]);
- if (!single_test())
- {
- kprintf("ht_test failed\n");
- return false;
- }
- }
-
- kprintf("ht_test successful\n");
- return true;
-}
-
-#endif