/* * d i c t C r e a t e W o r d l i s t * Create and initialize an anonymous wordlist */ ficlHash * ficlDictionaryCreateWordlist(ficlDictionary *dictionary, int bucketCount) { ficlHash *hash; ficlDictionaryAlign(dictionary); hash = (ficlHash *)dictionary->here; ficlDictionaryAllot(dictionary, sizeof (ficlHash) + (bucketCount - 1) * sizeof (ficlWord *)); hash->size = bucketCount; ficlHashReset(hash); return (hash); }
void * ficlDictionaryAppendData(ficlDictionary *dictionary, void *data, ficlInteger length) { char *here = (char *)dictionary->here; char *oldHere = here; char *from = (char *)data; if (length == 0) { ficlDictionaryAlign(dictionary); return ((char *)dictionary->here); } while (length) { *here++ = *from++; length--; } *here++ = '\0'; dictionary->here = FICL_POINTER_TO_CELL(here); ficlDictionaryAlign(dictionary); return (oldHere); }
/* * d i c t E m p t y * Empty the dictionary, reset its hash table, and reset its search order. * Clears and (re-)creates the hash table with the size specified by nHash. */ void ficlDictionaryEmpty(ficlDictionary *dictionary, unsigned bucketCount) { ficlHash *hash; dictionary->here = dictionary->base; ficlDictionaryAlign(dictionary); hash = (ficlHash *)dictionary->here; ficlDictionaryAllot(dictionary, sizeof (ficlHash) + (bucketCount - 1) * sizeof (ficlWord *)); hash->size = bucketCount; ficlHashReset(hash); dictionary->forthWordlist = hash; dictionary->smudge = NULL; ficlDictionaryResetSearchOrder(dictionary); }
FICL_PLATFORM_EXTERN void dictAlign (ficlDictionary *dictionary) { ficlDictionaryAlign(dictionary); }