base: free memory of object throwing exception

in constructor.

Extend test case to verify it and run it by autopilot.
This commit is contained in:
Alexander Boettcher 2016-11-23 13:05:28 +01:00 committed by Christian Helmuth
parent 7f78d182f8
commit 33b40ec5d9
3 changed files with 16 additions and 0 deletions

View File

@ -249,6 +249,19 @@ void operator delete (void *, Genode::Deallocator *);
void operator delete (void *, Genode::Deallocator &);
/**
* The compiler looks for a delete operator signature matching the one of the
* new operator. If none is found, it omits (silently!) the generation of
* implicitly delete calls, which are needed when an exception is thrown within
* the constructor of the object.
*/
inline void operator delete (void *ptr, Genode::Allocator *a) {
operator delete (ptr, static_cast<Genode::Deallocator *>(a)); }
inline void operator delete (void *ptr, Genode::Allocator &a) {
operator delete (ptr, *static_cast<Genode::Deallocator *>(&a)); }
/**
* Destroy object
*

View File

@ -49,6 +49,7 @@ compare_output_to {
[init -> test-new_delete] ~B
[init -> test-new_delete] ~C
[init -> test-new_delete] ~A
[init -> test-new_delete] Allocator::free()
[init -> test-new_delete] exception caught
[init -> test-new_delete] Allocator::alloc()
[init -> test-new_delete] A
@ -73,6 +74,7 @@ compare_output_to {
[init -> test-new_delete] ~B
[init -> test-new_delete] ~C
[init -> test-new_delete] ~A
[init -> test-new_delete] Allocator::free()
[init -> test-new_delete] exception caught
}

View File

@ -74,3 +74,4 @@ cpu_sampler
cpu_sampler_noux
usb_hid
smartcard
new_delete