2017-01-31 15:00:58 +00:00
|
|
|
/*
|
|
|
|
* \brief Genode::Allocator that uses the libc's global heap
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2017-01-31
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Genode Labs GmbH
|
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2017-01-31 15:00:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__LIBC__ALLOCATOR_H_
|
|
|
|
#define _INCLUDE__LIBC__ALLOCATOR_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/allocator.h>
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
namespace Libc { struct Allocator; }
|
|
|
|
|
|
|
|
|
|
|
|
struct Libc::Allocator : Genode::Allocator
|
|
|
|
{
|
|
|
|
typedef Genode::size_t size_t;
|
|
|
|
|
2021-11-10 11:01:32 +00:00
|
|
|
Alloc_result try_alloc(size_t size) override { return malloc(size); }
|
2017-01-31 15:00:58 +00:00
|
|
|
|
|
|
|
void free(void *addr, size_t size) override { ::free(addr); }
|
|
|
|
|
|
|
|
bool need_size_for_free() const override { return false; }
|
|
|
|
|
|
|
|
size_t overhead(size_t size) const override { return 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__LIBC__ALLOCATOR_H_ */
|