void lrw_dict_put(LRWDict *d, const Term *key, const void *value) { dictEntry *entry = dictFind(d->dict, key); // pstring *t = term_to_s(key); // printf("adding %.*s to size %d\n", t->len, t->val,dictSize(d->dict)); if(entry == NULL) { if(dictSize(d->dict) >= d->capacity) { _truncate(d); } entry = dictAddRaw(d->dict, (void *) key); if(!entry && dictIsRehashing(d->dict)) { entry = dictFind(d->dict, key); } assert(entry); } dictSetVal(d->dict, entry, (void *) value); _bump(d, entry->key); }
void mp_init_buffers(void) { mpBuf_t *pv; uint8_t i; memset(&mb, 0, sizeof(mb)); // clear all values, pointers and status mb.magic_start = MAGICNUM; mb.magic_end = MAGICNUM; mb.w = &mb.bf[0]; // init write and read buffer pointers mb.q = &mb.bf[0]; mb.r = &mb.bf[0]; pv = &mb.bf[PLANNER_BUFFER_POOL_SIZE-1]; for (i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) { // setup ring pointers mb.bf[i].nx = &mb.bf[_bump(i)]; mb.bf[i].pv = pv; pv = &mb.bf[i]; } mb.buffers_available = PLANNER_BUFFER_POOL_SIZE; }