#include "MQTTExportDeclarations.h"
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
void * | Heap_findItem (void *p) |
|
LIBMQTT_API heap_info * | Heap_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) |
|
#define free |
( |
|
x | ) |
myfree(__FILE__, __LINE__, x) |
redefines free to use "myfree" so that heap allocation can be tracked
- Parameters
-
x | the 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
-
x | the 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 |
#define realloc |
( |
|
a, |
|
|
|
b |
|
) |
| myrealloc(__FILE__, __LINE__, a, b) |
redefines realloc to use "myrealloc" so that heap allocation can be tracked
- Parameters
-
a | the heap item to be reallocated |
b | the new size of the item |
- Returns
- the new pointer to the heap item
Definition at line 49 of file Heap.h.
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
-
p | pointer to a memory location |
- Returns
- pointer to the storage element if found, or NULL
Definition at line 368 of file Heap.c.
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
-
file | use the FILE macro to indicate which file this item was allocated in |
line | use the LINE macro to indicate which line this item was allocated at |
p | pointer 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
-
file | file 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
-
file | file handle to dump the heap contents to |
str | the 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
-
file | use the FILE macro to indicate which file this item was allocated in |
line | use the LINE macro to indicate which line this item was allocated at |
p | pointer 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
-
file | use the FILE macro to indicate which file this item was allocated in |
line | use the LINE macro to indicate which line this item was allocated at |
size | the 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
-
file | use the FILE macro to indicate which file this item was reallocated in |
line | use the LINE macro to indicate which line this item was reallocated at |
p | pointer to the item to be reallocated |
size | the 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.