Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created November 1, 2010 23:02
Show Gist options
  • Select an option

  • Save tomas-stefano/659024 to your computer and use it in GitHub Desktop.

Select an option

Save tomas-stefano/659024 to your computer and use it in GitHub Desktop.
Dictionary from Redis
// 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;
@tomas-stefano
Copy link
Copy Markdown
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