Offers interface for allocating & freeing blocks of memory. This is a test memory manager which checks for writing beyond the allocated memory block. It is used during the execution of unit tests.
Test-MemoryManager | Offers interface for allocating & freeing blocks of memory. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Test-MemoryManager. |
C-kern/ | Implementation file Test-MemoryManager impl. |
Types | |
struct testmm_t | Exports testmm_t. |
Functions | |
test | |
unittest_test_mm_testmm | |
testmm_t | Test memory manager for allocating/freeing blocks of memory. |
context | |
isinstalled_testmm | Returns true if test memory manager is installed. |
mmcontext_testmm | Returns the installed testmm_t memory manager or 0. |
switchon_testmm | Stores current memory manager of threadcontext_t and installs testmm_t. |
switchoff_testmm | Restores memory manager of threadcontext_t. |
lifetime | |
testmm_FREE | Static initializer. |
init_testmm | Initializes a new test memory manager. |
free_testmm | Frees all memory managed by this manager. |
initasmm_testmm | Calls init_testmm and wraps object into interface object mm_t. |
freeasmm_testmm | Calls free_testmm with object pointer from mm_t. |
query | |
sizeallocated_testmm | Returns the size in bytes of all allocated memory blocks. |
allocate | |
malloc_testmm | Allocates a new memory block. |
mresize_testmm | Allocates new or resizes already allocated memory block. |
mfree_testmm | Frees the memory of an allocated memory block. |
inline implementation | |
Macros | |
isinstalled_testmm | Implements testmm_t.isinstalled_testmm. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file Test-MemoryManager.
Implementation file Test-MemoryManager impl.
typedef struct testmm_t testmm_t
Exports testmm_t.
struct testmm_t
Test memory manager for allocating/freeing blocks of memory.
context | |
isinstalled_testmm | Returns true if test memory manager is installed. |
mmcontext_testmm | Returns the installed testmm_t memory manager or 0. |
switchon_testmm | Stores current memory manager of threadcontext_t and installs testmm_t. |
switchoff_testmm | Restores memory manager of threadcontext_t. |
lifetime | |
testmm_FREE | Static initializer. |
init_testmm | Initializes a new test memory manager. |
free_testmm | Frees all memory managed by this manager. |
initasmm_testmm | Calls init_testmm and wraps object into interface object mm_t. |
freeasmm_testmm | Calls free_testmm with object pointer from mm_t. |
query | |
sizeallocated_testmm | Returns the size in bytes of all allocated memory blocks. |
allocate | |
malloc_testmm | Allocates a new memory block. |
mresize_testmm | Allocates new or resizes already allocated memory block. |
mfree_testmm | Frees the memory of an allocated memory block. |
testmm_t * mmcontext_testmm( void )
Returns the installed testmm_t memory manager or 0. If no memory manager of type testmm_t was installed with a previous call to switchon_testmm the value 0 is returned.
int switchon_testmm( void )
Stores current memory manager of threadcontext_t and installs testmm_t.
int switchoff_testmm( void )
Restores memory manager of threadcontext_t. The test memory manager in use (testmm_t) is freed and the memory manager in threadcontext_t is restored to one which was in used before switchon_testmm was called.
int initasmm_testmm( /*out*/struct mm_t * testmm )
Calls init_testmm and wraps object into interface object mm_t. This function is called from switchon_testmm.
int freeasmm_testmm( struct mm_t * testmm )
Calls free_testmm with object pointer from mm_t. This function is called from switchoff_testmm.
#define isinstalled_testmm( ) (0 != mmcontext_testmm())
Implements testmm_t.isinstalled_testmm.
Exports testmm_t.
typedef struct testmm_t testmm_t
Test memory manager for allocating/freeing blocks of memory.
struct testmm_t
int unittest_test_mm_testmm( void )
Returns true if test memory manager is installed.
bool isinstalled_testmm( void )
Returns the installed testmm_t memory manager or 0.
testmm_t * mmcontext_testmm( void )
Stores current memory manager of threadcontext_t and installs testmm_t.
int switchon_testmm( void )
Restores memory manager of threadcontext_t.
int switchoff_testmm( void )
Static initializer.
#define testmm_FREE { 0, 0 }
Initializes a new test memory manager.
int init_testmm( /*out*/testmm_t * mman )
Frees all memory managed by this manager.
int free_testmm( testmm_t * mman )
Calls init_testmm and wraps object into interface object mm_t.
int initasmm_testmm( /*out*/struct mm_t * testmm )
Uses iobj_DECLARE to declare interfaceable object.
iobj_DECLARE( mm_t, mm )
Calls free_testmm with object pointer from mm_t.
int freeasmm_testmm( struct mm_t * testmm )
Returns the size in bytes of all allocated memory blocks.
size_t sizeallocated_testmm( testmm_t * mman )
Allocates a new memory block.
int malloc_testmm( testmm_t * mman, size_t size, /*out*/struct memblock_t * memblock )
Allocates new or resizes already allocated memory block.
int mresize_testmm( testmm_t * mman, size_t newsize, struct memblock_t * memblock )
Frees the memory of an allocated memory block.
int mfree_testmm( testmm_t * mman, struct memblock_t * memblock )
Implements testmm_t.isinstalled_testmm.
#define isinstalled_testmm( ) (0 != mmcontext_testmm())