Пример #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;
}
Пример #2
0
Файл: memory.c Проект: 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;
}
Пример #3
0
Файл: memory.c Проект: 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;
}
Пример #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;
}
Пример #5
0
Файл: memory.c Проект: 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);
}
Пример #6
0
Файл: memory.c Проект: 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);
}
Пример #7
0
Файл: memory.c Проект: 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;
}
Пример #8
0
Файл: memory.c Проект: 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;
}
Пример #9
0
Файл: memory.c Проект: 8l/SECD
cell_t *new_number(secd_t *secd, int num) {
    cell_t *cell = pop_free(secd);
    return init_number(cell, num);
}
Пример #10
0
Файл: memory.c Проект: 8l/SECD
cell_t *new_cons(secd_t *secd, cell_t *car, cell_t *cdr) {
    return init_cons(secd, pop_free(secd), car, cdr);
}