From cf0c6d32474e346c6fc0733029b455edc1329da3 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Tue, 17 Mar 2020 14:17:38 +0530 Subject: [PATCH] AP_HAL: ensure libc realloc is available for all platforms except ChibiOS --- libraries/AP_HAL/AP_HAL_Boards.h | 4 ++++ libraries/AP_HAL/Util.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index 71bdf2019c..374186d54b 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -232,3 +232,7 @@ #else #define AP_UAVCAN_SLCAN_ENABLED 0 #endif + +#ifndef USE_LIBC_REALLOC +#define USE_LIBC_REALLOC 1 +#endif diff --git a/libraries/AP_HAL/Util.h b/libraries/AP_HAL/Util.h index b85c9f8cc8..142a6a4c89 100644 --- a/libraries/AP_HAL/Util.h +++ b/libraries/AP_HAL/Util.h @@ -151,7 +151,11 @@ public: // heap functions, note that a heap once alloc'd cannot be dealloc'd virtual void *allocate_heap_memory(size_t size) = 0; virtual void *heap_realloc(void *heap, void *ptr, size_t new_size) = 0; +#if USE_LIBC_REALLOC virtual void *std_realloc(void *ptr, size_t new_size) { return realloc(ptr, new_size); } +#else + virtual void *std_realloc(void *ptr, size_t new_size) = 0; +#endif // USE_LIBC_REALLOC #endif // ENABLE_HEAP