AP_HAL_Linux: added old_size to heap_realloc
This commit is contained in:
parent
13cbccc016
commit
deb86be1da
@ -253,7 +253,7 @@ void *Util::allocate_heap_memory(size_t size)
|
|||||||
return (void *)new_heap;
|
return (void *)new_heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Util::heap_realloc(void *h, void *ptr, size_t new_size)
|
void *Util::heap_realloc(void *h, void *ptr, size_t old_size, size_t new_size)
|
||||||
{
|
{
|
||||||
if (h == nullptr) {
|
if (h == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -261,8 +261,10 @@ void *Util::heap_realloc(void *h, void *ptr, size_t new_size)
|
|||||||
|
|
||||||
struct heap *heapp = (struct heap*)h;
|
struct heap *heapp = (struct heap*)h;
|
||||||
|
|
||||||
// extract appropriate headers
|
// extract appropriate headers. We use the old_size from the
|
||||||
size_t old_size = 0;
|
// header not from the caller. We use SITL to catch cases they
|
||||||
|
// don't match (which would be a lua bug)
|
||||||
|
old_size = 0;
|
||||||
heap_allocation_header *old_header = nullptr;
|
heap_allocation_header *old_header = nullptr;
|
||||||
if (ptr != nullptr) {
|
if (ptr != nullptr) {
|
||||||
old_header = ((heap_allocation_header *)ptr) - 1;
|
old_header = ((heap_allocation_header *)ptr) - 1;
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
#ifdef ENABLE_HEAP
|
#ifdef ENABLE_HEAP
|
||||||
// heap functions, note that a heap once alloc'd cannot be dealloc'd
|
// heap functions, note that a heap once alloc'd cannot be dealloc'd
|
||||||
virtual void *allocate_heap_memory(size_t size) override;
|
virtual void *allocate_heap_memory(size_t size) override;
|
||||||
virtual void *heap_realloc(void *h, void *ptr, size_t new_size) override;
|
virtual void *heap_realloc(void *h, void *ptr, size_t old_size, size_t new_size) override;
|
||||||
#endif // ENABLE_HEAP
|
#endif // ENABLE_HEAP
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user