Skip to content

Instantly share code, notes, and snippets.

@adh
Created March 26, 2009 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adh/86328 to your computer and use it in GitHub Desktop.
Save adh/86328 to your computer and use it in GitHub Desktop.
char* dfsch_get_next_symbol(dfsch_symbol_iter_t **iter){ // deep magic
if (*iter == NULL){
*iter = GC_MALLOC(sizeof(dfsch_symbol_iter_t));
(*iter)->bucket = 0;
(*iter)->item = global_symbol_hash[(*iter)->bucket];
}
while ((*iter)->bucket < HASH_SIZE){
if (!(*iter)->item){
(*iter)->bucket ++;
(*iter)->item = global_symbol_hash[(*iter)->bucket];
}else{
hash_entry_t *i = (*iter)->item;
(*iter)->item = (*iter)->item->next;
return i->entry->data;
}
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment