mirror of
https://github.com/utoni/nDPId.git
synced 2026-05-05 19:15:06 +00:00
Merge commit 'c8bf38e5fb' as 'dependencies/uthash'
This commit is contained in:
commit
00e5132a80
250 changed files with 20767 additions and 0 deletions
44
dependencies/uthash/tests/test21.c
vendored
Normal file
44
dependencies/uthash/tests/test21.c
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "uthash.h"
|
||||
|
||||
typedef struct {
|
||||
char a;
|
||||
int b;
|
||||
} record_key_t;
|
||||
|
||||
typedef struct {
|
||||
record_key_t key;
|
||||
/* ... other data ... */
|
||||
UT_hash_handle hh;
|
||||
} record_t;
|
||||
|
||||
int main()
|
||||
{
|
||||
record_t l, *p, *r, *tmp, *records = NULL;
|
||||
|
||||
r = (record_t*)malloc( sizeof(record_t) );
|
||||
if (r == NULL) {
|
||||
exit(-1);
|
||||
}
|
||||
memset(r, 0, sizeof(record_t));
|
||||
r->key.a = 'a';
|
||||
r->key.b = 1;
|
||||
HASH_ADD(hh, records, key, sizeof(record_key_t), r);
|
||||
|
||||
memset(&l, 0, sizeof(record_t));
|
||||
l.key.a = 'a';
|
||||
l.key.b = 1;
|
||||
HASH_FIND(hh, records, &l.key, sizeof(record_key_t), p);
|
||||
|
||||
if (p != NULL) {
|
||||
printf("found %c %d\n", p->key.a, p->key.b);
|
||||
}
|
||||
|
||||
HASH_ITER(hh, records, p, tmp) {
|
||||
HASH_DEL(records, p);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue