mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 07:08:18 +00:00
committed by
Christian Helmuth
parent
7bed3967ae
commit
e370e08e01
@ -11,18 +11,13 @@
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <util/construct_at.h>
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/log.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**
|
||||
* Placement operator - tool for directly calling a constructor
|
||||
*/
|
||||
inline void *operator new(size_t, void *at) { return at; }
|
||||
|
||||
|
||||
/**************************
|
||||
** Block Implementation **
|
||||
**************************/
|
||||
@ -102,13 +97,11 @@ void Allocator_avl_base::Block::recompute()
|
||||
|
||||
Allocator_avl_base::Block *Allocator_avl_base::_alloc_block_metadata()
|
||||
{
|
||||
void *b = 0;
|
||||
void *b = nullptr;
|
||||
if (_md_alloc->alloc(sizeof(Block), &b))
|
||||
return construct_at<Block>(b, 0, 0, 0);
|
||||
|
||||
/* call constructor by using the placement new operator */
|
||||
return new((Block *)b) Block(0, 0, 0);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +124,7 @@ int Allocator_avl_base::_add_block(Block *block_metadata,
|
||||
return -1;
|
||||
|
||||
/* call constructor for new block */
|
||||
new (block_metadata) Block(base, size, used);
|
||||
construct_at<Block>(block_metadata, base, size, used);
|
||||
|
||||
/* insert block into avl tree */
|
||||
_addr_tree.insert(block_metadata);
|
||||
|
@ -237,7 +237,7 @@ Signal_context_capability Signal_receiver::manage(Signal_context *context)
|
||||
[&] () {
|
||||
size_t const quota = 1024*sizeof(long);
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "ram_quota=%zu", quota);
|
||||
snprintf(buf, sizeof(buf), "ram_quota=%ld", quota);
|
||||
|
||||
log("upgrading quota donation for PD session (", quota, " bytes)");
|
||||
|
||||
|
@ -54,7 +54,7 @@ bool Sliced_heap::alloc(size_t size, void **out_addr)
|
||||
_ram_session.free(ds_cap);
|
||||
return false;
|
||||
} catch (Ram_session::Alloc_failed) {
|
||||
error("Could not allocate dataspace with size %zu", size);
|
||||
error("Could not allocate dataspace with size %lu", size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,10 @@ static void *try_alloc(Allocator *alloc, size_t size)
|
||||
}
|
||||
|
||||
|
||||
void *operator new (size_t s, Allocator *a) { return try_alloc(a, s); }
|
||||
void *operator new [] (size_t s, Allocator *a) { return try_alloc(a, s); }
|
||||
void *operator new (size_t s, Allocator &a) { return a.alloc(s); }
|
||||
void *operator new [] (size_t s, Allocator &a) { return a.alloc(s); }
|
||||
void *operator new (__SIZE_TYPE__ s, Allocator *a) { return try_alloc(a, s); }
|
||||
void *operator new [] (__SIZE_TYPE__ s, Allocator *a) { return try_alloc(a, s); }
|
||||
void *operator new (__SIZE_TYPE__ s, Allocator &a) { return a.alloc(s); }
|
||||
void *operator new [] (__SIZE_TYPE__ s, Allocator &a) { return a.alloc(s); }
|
||||
|
||||
|
||||
static void try_dealloc(void *ptr, Deallocator &dealloc)
|
||||
|
Reference in New Issue
Block a user