mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
Vancouver: zero initialize memory of the heap
Classes in Vancouver expect to get zero initialised memory when using memory from the heap. Some classes don't initialize member variables as they should do.
This commit is contained in:
parent
11a262c1af
commit
79b0a7a2c9
@ -94,13 +94,19 @@ void *heap_alloc(unsigned int size)
|
||||
|
||||
void *operator new[](unsigned int size)
|
||||
{
|
||||
return heap_alloc(size);
|
||||
void * addr = heap_alloc(size);
|
||||
if (addr)
|
||||
Genode::memset(addr, 0, size);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
void *operator new[](unsigned int size, unsigned int align)
|
||||
{
|
||||
void *res = heap_alloc(size + align);
|
||||
if (res)
|
||||
Genode::memset(res, 0, size + align);
|
||||
void *aligned_res = (void *)(((Genode::addr_t)res & ~(align - 1)) + align);
|
||||
return aligned_res;
|
||||
}
|
||||
@ -108,7 +114,10 @@ void *operator new[](unsigned int size, unsigned int align)
|
||||
|
||||
void *operator new (unsigned int size)
|
||||
{
|
||||
return heap_alloc(size);
|
||||
void * addr = heap_alloc(size);
|
||||
if (addr)
|
||||
Genode::memset(addr, 0, size);
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user