Esempio n. 1
0
MemoryBlock<T,NSLAB>::MemoryBlock()
  : first_slab(0),
    current_slab(0),
    last_slab(0),
    next_free(0)
{
  first_slab = new_slab();
  current_slab = first_slab;
  last_slab = first_slab;
  next_free = current_slab->block;
}
Esempio n. 2
0
static struct slab *get_slab(struct slab_cache *cache)
{
	struct slab *slab;
	if (rb_empty(&cache->partial) && rb_empty(&cache->empty)) {
		slab = new_slab(cache);
		slab_insert(&cache->partial, slab);
		return slab;
	}

	if (rb_empty(&cache->partial))
		return slab_entry(rb_root(&cache->empty));
	return slab_entry(rb_root(&cache->partial));
}