genode/repos/base/include/base/tslab.h

34 lines
745 B
C
Raw Normal View History

2011-12-22 16:19:25 +01:00
/*
* \brief Typed slab allocator
* \author Norman Feske
* \date 2006-05-17
*/
/*
2013-01-10 21:44:47 +01:00
* Copyright (C) 2006-2013 Genode Labs GmbH
2011-12-22 16:19:25 +01:00
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__BASE__TSLAB_H_
#define _INCLUDE__BASE__TSLAB_H_
#include <base/slab.h>
namespace Genode { template <typename, size_t> struct Tslab; }
2011-12-22 16:19:25 +01:00
template <typename T, Genode::size_t BLOCK_SIZE>
struct Genode::Tslab : Slab
{
Tslab(Allocator *backing_store,
Slab_block *initial_sb = 0)
: Slab(sizeof(T), BLOCK_SIZE, initial_sb, backing_store)
{ }
2011-12-22 16:19:25 +01:00
T *first_object() { return (T *)Slab::first_used_elem(); }
};
2011-12-22 16:19:25 +01:00
#endif /* _INCLUDE__BASE__TSLAB_H_ */