Mark Radbourne / Mbed 2 deprecated iothub_client_sample_amqp

Dependencies:   EthernetInterface NTPClient iothub_amqp_transport iothub_client mbed-rtos mbed

Fork of iothub_client_sample_amqp by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gballoc.h Source File

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 
00008 #ifdef __cplusplus
00009 #include <cstdlib>
00010 extern "C"
00011 {
00012 #else
00013 #include <stdlib.h>
00014 #endif
00015 #ifdef _CRTDBG_MAP_ALLOC
00016 #include <crtdbg.h>
00017 #endif
00018 
00019 #include "azure_c_shared_utility/umock_c_prod.h"
00020 
00021 /* all translation units that need memory measurement need to have GB_MEASURE_MEMORY_FOR_THIS defined */
00022 /* GB_DEBUG_ALLOC is the switch that turns the measurement on/off, so that it is not on always */
00023 #if defined(GB_DEBUG_ALLOC)
00024 
00025 MOCKABLE_FUNCTION(, int, gballoc_init);
00026 MOCKABLE_FUNCTION(, void, gballoc_deinit);
00027 MOCKABLE_FUNCTION(, void*, gballoc_malloc, size_t, size);
00028 MOCKABLE_FUNCTION(, void*, gballoc_calloc, size_t, nmemb, size_t, size);
00029 MOCKABLE_FUNCTION(, void*, gballoc_realloc, void*, ptr, size_t, size);
00030 MOCKABLE_FUNCTION(, void, gballoc_free, void*, ptr);
00031 
00032 MOCKABLE_FUNCTION(, size_t, gballoc_getMaximumMemoryUsed);
00033 MOCKABLE_FUNCTION(, size_t, gballoc_getCurrentMemoryUsed);
00034 
00035 /* if GB_MEASURE_MEMORY_FOR_THIS is defined then we want to redirect memory allocation functions to gballoc_xxx functions */
00036 #ifdef GB_MEASURE_MEMORY_FOR_THIS
00037 #if defined(_CRTDBG_MAP_ALLOC) && defined(_DEBUG)
00038 #undef _malloc_dbg
00039 #undef _calloc_dbg
00040 #undef _realloc_dbg
00041 #undef _free_dbg
00042 #define _malloc_dbg(size, ...) gballoc_malloc(size)
00043 #define _calloc_dbg(nmemb, size, ...) gballoc_calloc(nmemb, size)
00044 #define _realloc_dbg(ptr, size, ...) gballoc_realloc(ptr, size)
00045 #define _free_dbg(ptr, ...) gballoc_free(ptr)
00046 #else
00047 #define malloc gballoc_malloc
00048 #define calloc gballoc_calloc
00049 #define realloc gballoc_realloc
00050 #define free gballoc_free
00051 #endif
00052 #endif
00053 
00054 #else /* GB_DEBUG_ALLOC */
00055 
00056 #define gballoc_init() 0
00057 #define gballoc_deinit() ((void)0)
00058 
00059 #define gballoc_getMaximumMemoryUsed() SIZE_MAX
00060 #define gballoc_getCurrentMemoryUsed() SIZE_MAX
00061 
00062 #endif /* GB_DEBUG_ALLOC */
00063 
00064 #ifdef __cplusplus
00065 }
00066 #endif
00067 
00068 #endif /* GBALLOC_H */