Open janus opened 10 years ago
First off, thanks for the comments! I really appreciate you taking a look. This dict implementation is taken straight from Redis, so it might be better to raise questions upstream. I'm open to fixing obvious things, though.
Just trying to learn C by reading others' code. And lately I was trying to understand how web server works, and your code seems to be pretty easy to follow. However, I found a couple of things two hard to understand. I would need help to get through them
On Mon, Feb 17, 2014 at 3:14 AM, Kyle Maxwell notifications@github.comwrote:
First off, thanks for the comments! I really appreciate you taking a look. This dict implementation is taken straight from Redis, so it might be better to raise questions upstream. I'm open to fixing obvious things, though.
Reply to this email directly or view it on GitHubhttps://github.com/fizx/sit/issues/18#issuecomment-35223997 .
Satajanus Nig. Ltd
dictIterator _dictGetIterator(dict d) { dictIterator iter = malloc(sizeof(_iter));
}
No check to see if malloc actually creates heap object.
dictEntry dictNext(dictIterator iter) { while (1) { if (iter->entry == NULL) { dictht *ht = &iter->d->ht[iter->table]; if (iter->safe && iter->index == -1 && iter->table == 0) iter->d->iterators++; iter->index++; if (iter->index >= (signed) ht->size) { if (dictIsRehashing(iter->d) && iter->table == 0) { iter->table++; iter->index = 0; ht = &iter->d->ht[1]; } else { break; }
Looks like this code would break someday because of inconsistency,&iter->d->ht[iter->table] and &iter->d->ht[1]