Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
Arquivo: memory.c Projeto: 8l/SECD
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;
}
Exemplo n.º 3
0
Arquivo: memory.c Projeto: 8l/SECD
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
Arquivo: memory.c Projeto: 8l/SECD
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);
}
Exemplo n.º 6
0
Arquivo: memory.c Projeto: 8l/SECD
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);
}
Exemplo n.º 7
0
Arquivo: memory.c Projeto: 8l/SECD
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;
}
Exemplo n.º 8
0
Arquivo: memory.c Projeto: 8l/SECD
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;
}
Exemplo n.º 9
0
Arquivo: memory.c Projeto: 8l/SECD
cell_t *new_number(secd_t *secd, int num) {
    cell_t *cell = pop_free(secd);
    return init_number(cell, num);
}
Exemplo n.º 10
0
Arquivo: memory.c Projeto: 8l/SECD
cell_t *new_cons(secd_t *secd, cell_t *car, cell_t *cdr) {
    return init_cons(secd, pop_free(secd), car, cdr);
}