33 #define DEFAULT_SIZE 512 34 #define MAX_SIZE 65536 41 if (size & (size - 1)) {
42 fprintf(
stderr,
"gphInitPvt: %d is not a power of 2\n", size);
54 pgphPvt->
mask = size - 1;
74 gphlist = paplist[hash];
75 if (gphlist ==
NULL) {
82 if (pvtid == pgphNode->
pvtid &&
83 strlen(pgphNode->
name) == len &&
84 strncmp(name, pgphNode->
name, len) == 0)
break;
110 plist = paplist[hash];
112 plist = calloc(1,
sizeof(
ELLLIST));
118 paplist[hash] = plist;
123 if (pvtid == pgphNode->
pvtid &&
124 strcmp(name, pgphNode->
name) == 0) {
131 pgphNode = calloc(1,
sizeof(
GPHENTRY));
133 pgphNode->
name = name;
134 pgphNode->
pvtid = pvtid;
149 if (pgphPvt ==
NULL)
return;
155 if (paplist[hash] ==
NULL) {
158 plist = paplist[hash];
163 if (pvtid == pgphNode->
pvtid &&
164 strcmp(name, pgphNode->
name) == 0) {
166 free((
void *)pgphNode);
182 if (pgphPvt ==
NULL)
return;
185 for (h = 0; h < pgphPvt->
size; h++) {
190 if (plist ==
NULL)
continue;
213 unsigned int empty = 0;
220 fprintf(fp,
"Hash table has %d buckets", pgphPvt->
size);
223 for (h = 0; h < pgphPvt->
size; h++) {
234 fprintf(fp,
"\n [%3d] %3d ", h,
ellCount(plist));
238 fprintf(fp,
" %s %p", pgphNode->
name, pgphNode->
pvtid);
242 fprintf(fp,
"\n%u buckets empty.\n", empty);
unsigned int epicsStrHash(const char *str, unsigned int seed)
epics::pvData::BitSetPtr empty
void epicsStdCall gphFreeMem(gphPvt *pgphPvt)
#define ellCount(PLIST)
Report the number of nodes in a list.
void epicsStdCall epicsMutexDestroy(epicsMutexId pmutexNode)
Destroy an epicsMutex semaphore.
GPHENTRY *epicsStdCall gphFind(gphPvt *pgphPvt, const char *name, void *pvtid)
#define epicsMutexMustCreate()
Create an epicsMutex semaphore for use from C code.
void epicsStdCall gphInitPvt(gphPvt **ppvt, int size)
void epicsStdCall gphDumpFP(FILE *fp, gphPvt *pgphPvt)
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Miscellaneous macro definitions.
A doubly-linked list library.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define ellNext(PNODE)
Find the next node in list.
GPHENTRY *epicsStdCall gphAdd(gphPvt *pgphPvt, const char *name, void *pvtid)
APIs for the epicsMutex mutual exclusion semaphore.
void epicsStdCall gphDump(gphPvt *pgphPvt)
LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
A calloc() that never returns NULL.
unsigned int epicsMemHash(const char *str, size_t length, unsigned int seed)
#define ellInit(PLIST)
Initialize a list type.
void epicsStdCall gphDelete(gphPvt *pgphPvt, const char *name, void *pvtid)
GPHENTRY *epicsStdCall gphFindParse(gphPvt *pgphPvt, const char *name, size_t len, void *pvtid)
Routines for code that can't continue or return after an error.
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
#define ellFirst(PLIST)
Find the first node in list.