![]() |
mksqlite
2.5
A MATLAB interface to SQLite
|
Memory leak detection helper. More...
#include <vector>
Go to the source code of this file.
Classes | |
class | HeapCheck |
Helperclass for memory leak and access violation detection. More... | |
struct | HeapCheck::tagHeader |
Memory block header. More... | |
struct | HeapCheck::tagFooter |
Memory block footer (end marker) More... | |
Macros | |
#define | HC_ASSERT(exp) if (!(exp)) {HC_ASSERT_ERROR;} else |
#define | HC_NOTES(ptr, notes) HeapCheck.UpdateNotes(ptr,notes) |
#define | HC_COMP_ASSERT(exp) extern char _HC_CompAssert[(exp)?1:-1] |
Verifies design-time assumptions (exp ) at compile-time. | |
#define | HC_ABS(x) (((x)>0)?(x):-(x)) |
calculate absolute value | |
#define | HC_ISPOWER2(x) (!((x)&((x)-1))) |
check if is a power of 2 | |
#define | HC_ALIGNMENT (sizeof(int)) |
align to integer | |
#define | HC_DOALIGN(num) (((num)+HC_ALIGNMENT-1)&~(HC_ALIGNMENT-1)) |
memory alignment | |
#define | USE_HC_ASSERT |
Macro USE_HC_ASSERT must exist in every module which uses macro HC_ASSERT. More... | |
Functions | |
void | HC_ReportAssert (const char *file, const char *lpFunctionName, long line) |
Standard assert routine used by macro HC_ASSERT. More... | |
Variables | |
class HeapCheck | HeapCheck |
Instantiate HeapCheck object in main module. | |
Memory leak detection helper.
Inspired by "Writing Bug-Free C Code" by Jerry Jongerius
Definition in file heap_check.hpp.
struct HeapCheck::tagHeader |
Memory block header.
Each memory block is surrounded by additional information: A preceding header stores who is responsible to this memory, some additional notes (comments) an a pointer to the end of the memory block (footer). By checking consitency of header and footer, one can test, if any close memory (write) accesses violation occures.
Definition at line 66 of file heap_check.hpp.
Class Members | ||
---|---|---|
long | lLineNumber | line number or 0 |
const char * | lpFilename | filename or NULL |
tagFooter * | lpFooter | pointer to footer, contiguous to memory block |
const char * | lpFunctionName | function name |
void * | lpMem | pointer to memory block (contiguous to this header space) |
const char * | lpNotes | pointer to further notes or NULL |
struct HeapCheck::tagFooter |
Memory block footer (end marker)
The footer only holds a pointer to the memory block header and is used for consistence check only.
Definition at line 82 of file heap_check.hpp.
Class Members | ||
---|---|---|
tagHeader * | lpHeader | pointer to header of this memory block |
#define HC_ASSERT | ( | exp | ) | if (!(exp)) {HC_ASSERT_ERROR;} else |
Assert condition exp
with reporting
Definition at line 24 of file heap_check.hpp.
Referenced by HeapCheck::VerifyPtr().
#define HC_NOTES | ( | ptr, | |
notes | |||
) | HeapCheck.UpdateNotes(ptr,notes) |
Update field "notes" in memory block header
Definition at line 25 of file heap_check.hpp.
Referenced by MD5_func(), and regex_func().
#define USE_HC_ASSERT |
Macro USE_HC_ASSERT must exist in every module which uses macro HC_ASSERT.
Definition at line 37 of file heap_check.hpp.
void HC_ReportAssert | ( | const char * | file, |
const char * | lpFunctionName, | ||
long | line | ||
) |
Standard assert routine used by macro HC_ASSERT.
[in] | file | Callers filename |
[in] | lpFunctionName | Callers function name |
[in] | line | Callers line numer |
Definition at line 441 of file heap_check.hpp.