37 char (*
Compare)(
void *, uint16_t,
void *, uint16_t),
void (*
Free)(
void *))
69 if (ht->
array == NULL) {
80 if (ht->
array != NULL)
98 while (hashbucket != NULL) {
100 if (ht->
Free != NULL)
103 hashbucket = next_hashbucket;
108 if (ht->
array != NULL)
116 if (ht == NULL || data == NULL)
119 uint32_t hash = ht->
Hash(ht, data, datalen);
132 if (ht->
array[hash] == NULL) {
133 ht->
array[hash] = hb;
136 ht->
array[hash] = hb;
156 uint32_t hash = ht->
Hash(ht, data, datalen);
160 if (ht->
array[hash] == NULL) {
182 if (ht->
Free != NULL)
186 ht->
array[hash] = NULL;
197 if (ht->
Compare(hashbucket->
data,hashbucket->
size,data,datalen) == 1) {
211 if (prev_hashbucket == NULL) {
220 if (ht->
Free != NULL)
226 prev_hashbucket = hashbucket;
228 }
while (hashbucket != NULL);
239 if (
SCMemcmp(data1,data2,len1) != 0)
253 uint32_t hash = ht->
Hash(ht, data, datalen);
255 if (ht->
array[hash] == NULL) {
262 return hashbucket->
data;
265 }
while (hashbucket != NULL);
272 uint8_t *d = (uint8_t *)data;
276 for (i = 0; i < datalen; i++) {
277 if (i == 0) hash += (((uint32_t)*d++));
278 else if (i == 1) hash += (((uint32_t)*d++) * datalen);
279 else hash *= (((uint32_t)*d++) * i) + datalen + i;
297 static int HashListTableTestInit01 (
void)
308 static int HashListTableTestInit02 (
void)
318 static int HashListTableTestInit03 (
void)
332 static int HashListTableTestInit04 (
void)
342 static int HashListTableTestAdd01 (
void)
360 static int HashListTableTestAdd02 (
void)
378 static int HashListTableTestAdd03 (
void)
390 printf(
"ht->listhead == NULL: ");
395 printf(
"ht->listtail == NULL: ");
406 static int HashListTableTestAdd04 (
void)
423 printf(
"htb == NULL: ");
429 printf(
"rp2 == NULL: ");
434 printf(
"rp != rp2: ");
445 static int HashListTableTestFull01 (
void)
471 static int HashListTableTestFull02 (
void)
501 UtRegisterTest(
"HashListTableTestInit01", HashListTableTestInit01);
502 UtRegisterTest(
"HashListTableTestInit02", HashListTableTestInit02);
503 UtRegisterTest(
"HashListTableTestInit03", HashListTableTestInit03);
504 UtRegisterTest(
"HashListTableTestInit04", HashListTableTestInit04);
511 UtRegisterTest(
"HashListTableTestFull01", HashListTableTestFull01);
512 UtRegisterTest(
"HashListTableTestFull02", HashListTableTestFull02);