Created
November 1, 2010 23:02
-
-
Save tomas-stefano/659024 to your computer and use it in GitHub Desktop.
Dictionary from Redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // dict.h | |
| typedef struct dictEntry { | |
| void *key; | |
| void *val; | |
| struct dictEntry *next; | |
| } dictEntry; | |
| typedef struct dictht { | |
| dictEntry **table; | |
| unsigned long size; | |
| unsigned long sizemask; | |
| unsigned long used; | |
| } dictht; | |
| typedef struct dict { | |
| void *privdata; | |
| dictht ht[2]; | |
| int rehashidx; | |
| int iterators; | |
| } dict; | |
| typedef struct dictType { | |
| unsigned int (*hashFunction)(const void *key); // And what this line does?? | |
| void *(*keyDup)(void *privdata, const void *key); // And this? | |
| void *(*valDup)(void *privdata, const void *obj); // And this? | |
| int (*keyCompare)(void *privdata, const void *key1, const void *key2); // And this? | |
| void (*keyDestructor)(void *privdata, void *key); // And this? | |
| void (*valDestructor)(void *privdata, void *obj); // And this? | |
| } dictType; |
Author
@25 and ahead, first value in parentesis is a pointer to function. Every function is a pointer.
Author
How I access the entries(key and value) from the first dictht?
dict my_dict;
my_dict.ht[0].table[0]->key // ??
my_dict.ht[0].table[0]->value // ??
I reading three guides about pointers to pointers and I don't understand How I access this??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The line 10 is pointer to pointer.
And the line 18 is two elements of the dictht struct.
After searching and reading docs I understand this