mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-11 22:15:14 +00:00
51041c737c
src/chtbl.c, src/hashpjw.c and src/list.c are distributed under an obscure license. While Aleks and I believe that this license is OK for haproxy, other people think it is not compatible with the GPL. Whether it is or not is not the problem. The fact that it rises a doubt is sufficient for this problem to be addressed. Arnaud Cornet rewrote the unclear parts with clean GPLv2 and LGPL code. The hash algorithm has changed too and the code has been slightly simplified in the process. A lot of care has been taken in order to respect the original API as much as possible, including the LGPL for the exportable parts. The new code has not been thoroughly tested but it looks OK now.
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <common/sessionhash.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
appsess *a, *b, *c, *d, *tmp;
|
|
struct appsession_hash h;
|
|
int i;
|
|
|
|
a = malloc(sizeof(appsess));
|
|
b = malloc(sizeof(appsess));
|
|
c = malloc(sizeof(appsess));
|
|
d = malloc(sizeof(appsess));
|
|
|
|
a->sessid = "abcdefg";
|
|
b->sessid = "2c";
|
|
c->sessid = "pe";
|
|
d->sessid = "abbbbbccccb";
|
|
|
|
appsession_hash_init(&h, (void (*)())free);
|
|
appsession_hash_dump(&h);
|
|
appsession_hash_insert(&h, a);
|
|
appsession_hash_insert(&h, b);
|
|
appsession_hash_insert(&h, c);
|
|
appsession_hash_insert(&h, d);
|
|
|
|
appsession_hash_dump(&h);
|
|
|
|
printf("a: %p\n", a);
|
|
printf("b: %p\n", b);
|
|
printf("c: %p\n", c);
|
|
printf("d: %p\n", d);
|
|
printf("-------------\n");
|
|
printf("a: %p\n", appsession_hash_lookup(&h, "abcdefg"));
|
|
printf("b: %p\n", appsession_hash_lookup(&h, "2c"));
|
|
printf("c: %p\n", appsession_hash_lookup(&h, "pe"));
|
|
printf("d: %p\n", appsession_hash_lookup(&h, "abbbbbccccb"));
|
|
printf("null: %p\n", appsession_hash_lookup(&h, "non existant"));
|
|
|
|
|
|
appsession_hash_remove(&h, c);
|
|
appsession_hash_remove(&h, d);
|
|
|
|
appsession_hash_dump(&h);
|
|
|
|
printf("-- remove c,d\n");
|
|
printf("a: %p\n", appsession_hash_lookup(&h, "abcdefg"));
|
|
printf("b: %p\n", appsession_hash_lookup(&h, "2c"));
|
|
printf("c: %p\n", appsession_hash_lookup(&h, "pe"));
|
|
printf("d: %p\n", appsession_hash_lookup(&h, "abbbbbccccb"));
|
|
printf("null: %p\n", appsession_hash_lookup(&h, "non existant"));
|
|
|
|
appsession_hash_destroy(&h);
|
|
}
|