Пример #1
0
static void test_remove(struct btree *btree, struct ileaf *leaf, inum_t inum, int less)
{
	unsigned size = 0;
	char *attrs = ileaf_lookup(btree, inum, leaf, &size);
	printf("attrs %p, attrs size = %i\n", attrs, size);
	attrs = ileaf_resize(btree, inum, leaf, size - less);
}
Пример #2
0
Файл: ileaf.c Проект: Zkin/tux3
static int ileaf_write(struct btree *btree, tuxkey_t key_bottom,
		       tuxkey_t key_limit,
		       void *leaf, struct btree_key_range *key,
		       tuxkey_t *split_hint)
{
	struct ileaf_req *rq = container_of(key, struct ileaf_req, key);
	struct ileaf_attr_ops *attr_ops = btree->ops->private_ops;
	struct ileaf *ileaf = leaf;
	void *attrs;
	int size;

	assert(key->len == 1);

	size = attr_ops->encoded_size(btree, rq->data);
	assert(size);

	attrs = ileaf_resize(btree, key->start, ileaf, size);
	if (attrs == NULL) {
		/* There is no space to store */
		*split_hint = ileaf_split_hint(btree, ileaf, key->start, size);
		return -ENOSPC;
	}

	attr_ops->encode(btree, rq->data, attrs, size);

	key->start++;
	key->len--;

	return 0;
}
Пример #3
0
static void test_append(struct btree *btree, struct ileaf *leaf, inum_t inum, int more, char fill)
{
	unsigned size = 0;
	char *attrs = ileaf_lookup(btree, inum, leaf, &size);
	printf("attrs %p, attrs size = %i\n", attrs, size);
	attrs = ileaf_resize(btree, inum, leaf, size + more);
	memset(attrs + size, fill, more);
}