|
Functions | |
| size_t | qHasharrSize (int max) |
| Under-development. | |
| bool | qHasharrInit (Q_HASHARR *tbl, size_t memsize) |
| Under-development. | |
| bool | qHasharrClear (Q_HASHARR *tbl) |
| Under-development. | |
| bool | qHasharrPut (Q_HASHARR *tbl, char *key, char *value, int size) |
| Under-development. | |
| bool | qHasharrPutStr (Q_HASHARR *tbl, char *key, char *value) |
| Under-development. | |
| bool | qHasharrPutInt (Q_HASHARR *tbl, char *key, int value) |
| Under-development. | |
| char * | qHasharrGet (Q_HASHARR *tbl, char *key, int *size) |
| Under-development. | |
| char * | qHasharrGetStr (Q_HASHARR *tbl, char *key) |
| Under-development. | |
| int | qHasharrGetInt (Q_HASHARR *tbl, char *key) |
| Under-development. | |
| char * | qHasharrGetFirstKey (Q_HASHARR *tbl, int *idx) |
| Under-development. | |
| char * | qHasharrGetNextKey (Q_HASHARR *tbl, int *idx) |
| Under-development. | |
| bool | qHasharrRemove (Q_HASHARR *tbl, char *key) |
| Under-development. | |
| bool | qHasharrPrint (Q_HASHARR *tbl, FILE *out) |
| Under-development. | |
| bool | qHasharrStatus (Q_HASHARR *tbl, int *used, int *max) |
| Under-development. | |
int maxkeys = 1000; // calculate how many memory do we need int memsize = qHasharrSize(maxkeys * 2); // generally allocate double size of max to decrease hash collision // allocate memory Q_HASHARR *hasharr = (Q_HASHARR *)malloc(memsize); // initialize hash-table if(qHasharrInit(hasharr, memsize) == false) return -1; // put some sample data if(qHasharrPut(hasharr, "sample1", "binary", 6) == false) return -1; // hash-table full if(qHasharrPutStr(hasharr, "sample2", "string") == false) return -1; // hash-table full if(qHasharrPutInt(hasharr, "sample3", 3) == false) return -1; // hash-table full // fetch data int size; char *sample_bin = qHasharrGet(hasharr, "sample1", &size); char *sample_str = qHasharrGetStr(hasharr, "sample2"); int sample_int = qHasharrGetInt(hasharr, "sample3");
Another simple way to initialize hash-table.
// define data memory as much as you needed. char datamem[10 * 1024]; // just set the Q_HASHARR points to data memory. Q_HASHARR *hasharr = (Q_HASHARR *)datamem; // initialize hash-table. if(qHasharrInit(hasharr, sizeof(datamem)) == false) return -1;
You can create hash table on shared memory like below.
int maxkeys = 1000; int memsize = qHasharrSize(maxkeys * 2); // create shared memory int shmid = qShmInit(g_conf.szEgisdavdPidfile, 's', memsize, true); if(shmid < 0) return -1; // creation failed Q_HASHARR *hasharr = (Q_HASHARR *)qShmGet(shmid); // initialize hash-table if(qHasharrInit(hasharr, memsize) == false) return -1; (...your codes here...) // destroy shared memory qShmFree(shmid);
| size_t qHasharrSize | ( | int | max | ) |
Under-development.
| bool qHasharrInit | ( | Q_HASHARR * | tbl, | |
| size_t | memsize | |||
| ) |
Under-development.
| bool qHasharrClear | ( | Q_HASHARR * | tbl | ) |
Under-development.
| bool qHasharrPut | ( | Q_HASHARR * | tbl, | |
| char * | key, | |||
| char * | value, | |||
| int | size | |||
| ) |
Under-development.
| bool qHasharrPutStr | ( | Q_HASHARR * | tbl, | |
| char * | key, | |||
| char * | value | |||
| ) |
Under-development.
| bool qHasharrPutInt | ( | Q_HASHARR * | tbl, | |
| char * | key, | |||
| int | value | |||
| ) |
Under-development.
| char* qHasharrGet | ( | Q_HASHARR * | tbl, | |
| char * | key, | |||
| int * | size | |||
| ) |
Under-development.
| char* qHasharrGetStr | ( | Q_HASHARR * | tbl, | |
| char * | key | |||
| ) |
Under-development.
| int qHasharrGetInt | ( | Q_HASHARR * | tbl, | |
| char * | key | |||
| ) |
Under-development.
| char* qHasharrGetFirstKey | ( | Q_HASHARR * | tbl, | |
| int * | idx | |||
| ) |
Under-development.
char *key; int idx; for(key = qHasharrGetFirstKey(tbl, &idx); key != NULL; key = qHasharrGetNextKey(tbl, &idx) { char *value = qHasharrGetStr(tbl, key); }
| char* qHasharrGetNextKey | ( | Q_HASHARR * | tbl, | |
| int * | idx | |||
| ) |
Under-development.
| bool qHasharrRemove | ( | Q_HASHARR * | tbl, | |
| char * | key | |||
| ) |
Under-development.
| bool qHasharrPrint | ( | Q_HASHARR * | tbl, | |
| FILE * | out | |||
| ) |
Under-development.
| bool qHasharrStatus | ( | Q_HASHARR * | tbl, | |
| int * | used, | |||
| int * | max | |||
| ) |
Under-development.
| [Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference] |