Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
gballoc.h
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 00003 00004 #ifndef GBALLOC_H 00005 #define GBALLOC_H 00006 00007 #include "azure_c_shared_utility/umock_c_prod.h" 00008 00009 #ifdef __cplusplus 00010 #include <cstddef> 00011 #include <cstdlib> 00012 extern "C" 00013 { 00014 #else 00015 #include <stddef.h> 00016 #include <stdlib.h> 00017 #endif 00018 00019 // GB_USE_CUSTOM_HEAP disables the implementations in gballoc.c and 00020 // requires that an external library implement the gballoc_malloc family 00021 // declared here. 00022 #if defined(GB_USE_CUSTOM_HEAP) 00023 void* gballoc_malloc(size_t size); 00024 void* gballoc_calloc(size_t nmemb, size_t size); 00025 void* gballoc_realloc(void* ptr, size_t size); 00026 void gballoc_free(void* ptr); 00027 00028 #define malloc gballoc_malloc 00029 #define calloc gballoc_calloc 00030 #define realloc gballoc_realloc 00031 #define free gballoc_free 00032 00033 /* all translation units that need memory measurement need to have GB_MEASURE_MEMORY_FOR_THIS defined */ 00034 /* GB_DEBUG_ALLOC is the switch that turns the measurement on/off, so that it is not on always */ 00035 #elif defined(GB_DEBUG_ALLOC) 00036 00037 MOCKABLE_FUNCTION(, int, gballoc_init); 00038 MOCKABLE_FUNCTION(, void, gballoc_deinit); 00039 MOCKABLE_FUNCTION(, void*, gballoc_malloc, size_t, size); 00040 MOCKABLE_FUNCTION(, void*, gballoc_calloc, size_t, nmemb, size_t, size); 00041 MOCKABLE_FUNCTION(, void*, gballoc_realloc, void*, ptr, size_t, size); 00042 MOCKABLE_FUNCTION(, void, gballoc_free, void*, ptr); 00043 00044 MOCKABLE_FUNCTION(, size_t, gballoc_getMaximumMemoryUsed); 00045 MOCKABLE_FUNCTION(, size_t, gballoc_getCurrentMemoryUsed); 00046 MOCKABLE_FUNCTION(, size_t, gballoc_getAllocationCount); 00047 MOCKABLE_FUNCTION(, void, gballoc_resetMetrics); 00048 00049 /* if GB_MEASURE_MEMORY_FOR_THIS is defined then we want to redirect memory allocation functions to gballoc_xxx functions */ 00050 #ifdef GB_MEASURE_MEMORY_FOR_THIS 00051 /* Unfortunately this is still needed here for things to still compile when using _CRTDBG_MAP_ALLOC. 00052 That is because there is a rogue component (most likely CppUnitTest) including crtdbg. */ 00053 #if defined(_CRTDBG_MAP_ALLOC) && defined(_DEBUG) 00054 #undef _malloc_dbg 00055 #undef _calloc_dbg 00056 #undef _realloc_dbg 00057 #undef _free_dbg 00058 #define _malloc_dbg(size, ...) gballoc_malloc(size) 00059 #define _calloc_dbg(nmemb, size, ...) gballoc_calloc(nmemb, size) 00060 #define _realloc_dbg(ptr, size, ...) gballoc_realloc(ptr, size) 00061 #define _free_dbg(ptr, ...) gballoc_free(ptr) 00062 #else 00063 #define malloc gballoc_malloc 00064 #define calloc gballoc_calloc 00065 #define realloc gballoc_realloc 00066 #define free gballoc_free 00067 #endif 00068 #endif 00069 00070 #else /* GB_DEBUG_ALLOC */ 00071 00072 #define gballoc_init() 0 00073 #define gballoc_deinit() ((void)0) 00074 00075 #define gballoc_getMaximumMemoryUsed() SIZE_MAX 00076 #define gballoc_getCurrentMemoryUsed() SIZE_MAX 00077 #define gballoc_getAllocationCount() SIZE_MAX 00078 #define gballoc_resetMetrics() ((void)0) 00079 00080 #endif /* GB_DEBUG_ALLOC */ 00081 00082 #ifdef __cplusplus 00083 } 00084 #endif 00085 00086 #endif /* GBALLOC_H */
Generated on Wed Jul 13 2022 23:38:02 by
1.7.2
