Classes | Macros | Functions
Heap.h File Reference
#include "MQTTExportDeclarations.h"
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for Heap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  heap_info
 

Macros

#define free(x)   myfree(__FILE__, __LINE__, x)
 
#define malloc(x)   mymalloc(__FILE__, __LINE__, x)
 
#define PAHO_MEMORY_ERROR   -99
 
#define realloc(a, b)   myrealloc(__FILE__, __LINE__, a, b)
 

Functions

void * Heap_findItem (void *p)
 
LIBMQTT_API heap_infoHeap_get_info (void)
 
int Heap_initialize (void)
 
void Heap_scan (FILE *file)
 
void Heap_terminate (void)
 
void Heap_unlink (char *file, int line, void *p)
 
int HeapDump (FILE *file)
 
int HeapDumpString (FILE *file, char *str)
 
void myfree (char *, int, void *p)
 
void * mymalloc (char *, int, size_t size)
 
void * myrealloc (char *, int, void *p, size_t size)
 

Macro Definition Documentation

#define free (   x)    myfree(__FILE__, __LINE__, x)

redefines free to use "myfree" so that heap allocation can be tracked

Parameters
xthe size of the item to be freed

Definition at line 55 of file Heap.h.

#define malloc (   x)    mymalloc(__FILE__, __LINE__, x)

redefines malloc to use "mymalloc" so that heap allocation can be tracked

Parameters
xthe size of the item to be allocated
Returns
the pointer to the item allocated, or NULL

Definition at line 41 of file Heap.h.

#define PAHO_MEMORY_ERROR   -99

Definition at line 26 of file Heap.h.

#define realloc (   a,
 
)    myrealloc(__FILE__, __LINE__, a, b)

redefines realloc to use "myrealloc" so that heap allocation can be tracked

Parameters
athe heap item to be reallocated
bthe new size of the item
Returns
the new pointer to the heap item

Definition at line 49 of file Heap.h.

Function Documentation

void* Heap_findItem ( void *  p)

Utility to find an item in the heap. Lets you know if the heap already contains the memory location in question.

Parameters
ppointer to a memory location
Returns
pointer to the storage element if found, or NULL

Definition at line 368 of file Heap.c.

LIBMQTT_API heap_info* Heap_get_info ( void  )

Access to heap state

Returns
pointer to the heap state structure

Definition at line 432 of file Heap.c.

int Heap_initialize ( void  )

Heap initialization.

Definition at line 406 of file Heap.c.

void Heap_scan ( FILE *  file)
void Heap_terminate ( void  )

Heap termination.

Definition at line 417 of file Heap.c.

void Heap_unlink ( char *  file,
int  line,
void *  p 
)

Remove an item from the recorded heap without actually freeing it. Use sparingly!

Parameters
fileuse the FILE macro to indicate which file this item was allocated in
lineuse the LINE macro to indicate which line this item was allocated at
ppointer to the item to be removed

Definition at line 300 of file Heap.c.

int HeapDump ( FILE *  file)

Dump the state of the heap

Parameters
filefile handle to dump the heap contents to

Definition at line 462 of file Heap.c.

int HeapDumpString ( FILE *  file,
char *  str 
)

Dump a string from the heap so that it can be displayed conveniently

Parameters
filefile handle to dump the heap contents to
strthe string to dump, could be NULL

Definition at line 443 of file Heap.c.

void myfree ( char *  file,
int  line,
void *  p 
)

Frees a block of memory. A direct replacement for free, but checks that a item is in the allocates list first.

Parameters
fileuse the FILE macro to indicate which file this item was allocated in
lineuse the LINE macro to indicate which line this item was allocated at
ppointer to the item to be freed

Definition at line 277 of file Heap.c.

void* mymalloc ( char *  file,
int  line,
size_t  size 
)

Allocates a block of memory. A direct replacement for malloc, but keeps track of items allocated in a list, so that free can check that a item is being freed correctly and that we can check that all memory is freed at shutdown.

Parameters
fileuse the FILE macro to indicate which file this item was allocated in
lineuse the LINE macro to indicate which line this item was allocated at
sizethe size of the item to be allocated
Returns
pointer to the allocated item, or NULL if there was an error

Definition at line 158 of file Heap.c.

void* myrealloc ( char *  file,
int  line,
void *  p,
size_t  size 
)

Reallocates a block of memory. A direct replacement for realloc, but keeps track of items allocated in a list, so that free can check that a item is being freed correctly and that we can check that all memory is freed at shutdown. We have to remove the item from the tree, as the memory is in order and so it needs to be reinserted in the correct place.

Parameters
fileuse the FILE macro to indicate which file this item was reallocated in
lineuse the LINE macro to indicate which line this item was reallocated at
ppointer to the item to be reallocated
sizethe new size of the item
Returns
pointer to the allocated item, or NULL if there was an error

Definition at line 320 of file Heap.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:48