static void *BT_CacheAlloc(BT_CACHE *pCache) { struct block_free *p = pop_free(pCache); if(!p) { extend_cache(pCache); p = pop_free(pCache); if(!p) { return NULL; } } return (void *) p; }
cell_t *new_array_for(secd_t *secd, cell_t *mem) { cell_t *arr = pop_free(secd); arr->type = CELL_ARRAY; arr->as.arr.data = share_array(secd, mem); arr->as.arr.offset = 0; return arr; }
cell_t *new_symbol(secd_t *secd, const char *sym) { cell_t *cell = pop_free(secd); cell->type = CELL_SYM; cell->as.sym.size = strlen(sym); cell->as.sym.data = strdup(sym); cell->as.sym.hash = memhash(sym, cell->as.sym.size); return cell; }
void *BT_CacheAlloc(BT_CACHE *pCache) { SLAB_LOCK(pCache); struct block_free *p = pop_free(pCache); if(!p) { extend_cache(pCache); p = pop_free(pCache); if(!p) { SLAB_UNLOCK(pCache); return NULL; } } SLAB_UNLOCK(pCache); return (void *) p; }
cell_t *new_fileport(secd_t *secd, void *f, const char *mode) { cell_t *cell = pop_free(secd); assert_cell(cell, "new_fileport: allocation failed"); cell->type = CELL_PORT; cell->as.port.file = true; cell->as.port.as.file = f; return init_port_mode(secd, cell, mode); }
cell_t *new_strref(secd_t *secd, cell_t *mem, size_t size) { cell_t *ref = pop_free(secd); assert_cell(ref, "new_strref: allocation failed"); return init_strref(secd, ref, mem, size); }
cell_t *new_op(secd_t *secd, opindex_t opind) { cell_t *cell = pop_free(secd); cell->type = CELL_OP; cell->as.op = opind; return cell; }
cell_t *new_char(secd_t *secd, int c) { cell_t *cell = pop_free(secd); cell->type = CELL_CHAR; cell->as.num = c; return cell; }
cell_t *new_number(secd_t *secd, int num) { cell_t *cell = pop_free(secd); return init_number(cell, num); }
cell_t *new_cons(secd_t *secd, cell_t *car, cell_t *cdr) { return init_cons(secd, pop_free(secd), car, cdr); }