35#include <gwenhywfar/misc.h>
36#include <gwenhywfar/debug.h>
83 assert(map->setPairFn);
84 return map->setPairFn(map,
id, ptr);
93 assert(map->setPairFn);
94 return map->setPairFn(map,
id, 0);
102 assert(map->getPairFn);
103 return map->getPairFn(map,
id);
112 assert(map->findFirstFn);
113 return map->findFirstFn(map, pid);
122 assert(map->findNextFn);
123 return map->findNextFn(map, pid);
140 map->freeDataFn(map);
159 map->dumpFn(map, f, indent);
178 GWEN_IDMAP_HEX4 *xmap;
182 map->algoData=(
void *)xmap;
195 GWEN_IDMAP_HEX4 *xmap;
197 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
207 GWEN_IDMAP_HEX4_TABLE *t;
211 t->isPtrTable=isPtrTable;
220 if (!(t->isPtrTable)) {
223 for (i=0; i<16; i++) {
238 GWEN_IDMAP_HEX4 *xmap;
240 GWEN_IDMAP_HEX4_TABLE *t;
242 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
245 p=&(t->ptrs[(
id>>28) & 0xf]);
251 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
253 p=&(t->ptrs[(
id>>24) & 0xf]);
259 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
261 p=&(t->ptrs[(
id>>20) & 0xf]);
267 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
269 p=&(t->ptrs[(
id>>16) & 0xf]);
275 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
277 p=&(t->ptrs[(
id>>12) & 0xf]);
283 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
285 p=&(t->ptrs[(
id>>8) & 0xf]);
291 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
293 p=&(t->ptrs[(
id>>4) & 0xf]);
299 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
301 p=&(t->ptrs[
id & 0xf]);
309 GWEN_IDMAP_HEX4_TABLE *parent;
316 for (i=0; i<16; i++) {
324 parent->ptrs[
id & 0xf]=0;
338 GWEN_IDMAP_HEX4 *xmap;
339 GWEN_IDMAP_HEX4_TABLE *t;
341 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
346 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>28)&0xf]);
349 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>24)&0xf]);
352 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>20)&0xf]);
355 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>16)&0xf]);
358 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>12)&0xf]);
361 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>8)&0xf]);
364 t=(GWEN_IDMAP_HEX4_TABLE *)(t->ptrs[(
id>>4)&0xf]);
368 return (t->ptrs[
id & 0xf]);
378 p=&(t->ptrs[(
id>>28) & 0xf]);
381 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
383 p=&(t->ptrs[(
id>>24) & 0xf]);
386 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
388 p=&(t->ptrs[(
id>>20) & 0xf]);
391 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
393 p=&(t->ptrs[(
id>>16) & 0xf]);
396 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
398 p=&(t->ptrs[(
id>>12) & 0xf]);
401 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
403 p=&(t->ptrs[(
id>>8) & 0xf]);
406 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
408 p=&(t->ptrs[(
id>>4) & 0xf]);
411 t=(GWEN_IDMAP_HEX4_TABLE *) *p;
426 for (i=0; i<16; i++) {
436 GWEN_IDMAP_HEX4_TABLE *dt;
463 while (t && (
id & 0xf)==0xf) {
472 for (i=
id & 0xf; i<16; i++) {
476 lid=((
id & 0xfffffff0) | i);
482 GWEN_IDMAP_HEX4_TABLE *dt;
507 GWEN_IDMAP_HEX4_TABLE *t;
508 GWEN_IDMAP_HEX4 *xmap;
511 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
527 GWEN_IDMAP_HEX4_TABLE *t;
528 GWEN_IDMAP_HEX4 *xmap;
531 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
553 for (i=0; i<16; i++) {
557 for (j=0; j<indent; j++)
559 fprintf(f,
"Id: %01x Ptr: %p\n",
561 if (!(tbl->isPtrTable))
571 GWEN_IDMAP_HEX4 *xmap;
573 xmap=(GWEN_IDMAP_HEX4 *)map->algoData;
#define DBG_ERROR(dbg_logger, format,...)
GWEN_IDMAP_RESULT GWEN_IdMapHex4_FindNext(const GWEN_IDMAP *map, uint32_t *pid)
GWEN_IDMAP_RESULT GWEN_IdMap_GetNext(const GWEN_IDMAP *map, uint32_t *pid)
GWEN_IDMAP_HEX4_TABLE * GWEN_IdMapHex4__GetNextTable(GWEN_IDMAP_HEX4_TABLE *t, uint32_t *pid, int incr)
void GWEN_IdMap_Dump(GWEN_IDMAP *map, FILE *f, int indent)
void GWEN_IdMap_Clear(GWEN_IDMAP *map)
void * GWEN_IdMap_Find(GWEN_IDMAP *map, uint32_t id)
void GWEN_IdMap_free(GWEN_IDMAP *map)
GWEN_IDMAP * GWEN_IdMap_new(GWEN_IDMAP_ALGO algo)
void GWEN_IdMapHex4_Extend(GWEN_IDMAP *map)
GWEN_IDMAP_RESULT GWEN_IdMapHex4_Insert(GWEN_IDMAP *map, uint32_t id, void *ptr)
void GWEN_IdMapHex4Map_free(GWEN_IDMAP_HEX4_TABLE *t)
GWEN_IDMAP_RESULT GWEN_IdMap_Insert(GWEN_IDMAP *map, uint32_t id, void *ptr)
void GWEN_IdMapHex4_Dump(GWEN_IDMAP *map, FILE *f, int indent)
void * GWEN_IdMapHex4_Find(GWEN_IDMAP *map, uint32_t id)
GWEN_IDMAP_HEX4_TABLE * GWEN_IdMapHex4Map_new(GWEN_IDMAP_HEX4_TABLE *p, int isPtrTable)
void GWEN_IdMapHex4_free(GWEN_IDMAP *map)
GWEN_IDMAP_RESULT GWEN_IdMap_GetFirst(const GWEN_IDMAP *map, uint32_t *pid)
void GWEN_IdMapHex4__Dump(GWEN_IDMAP_HEX4_TABLE *tbl, FILE *f, int indent)
GWEN_IDMAP_RESULT GWEN_IdMapHex4_FindFirst(const GWEN_IDMAP *map, uint32_t *pid)
GWEN_IDMAP_HEX4_TABLE * GWEN_IdMapHex4__GetFirstTable(GWEN_IDMAP_HEX4_TABLE *t, uint32_t *pid)
uint32_t GWEN_IdMap_GetSize(const GWEN_IDMAP *map)
GWEN_IDMAP_RESULT GWEN_IdMap_Remove(GWEN_IDMAP *map, uint32_t id)
GWEN_IDMAP_HEX4_TABLE * GWEN_IdMapHex4__GetTable(GWEN_IDMAP_HEX4_TABLE *t, uint32_t id)
@ GWEN_IdMapResult_NotFound
struct GWEN_IDMAP GWEN_IDMAP
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)