Default implementation of mm_it. // TODO: rename into mm_default
DefaultMemoryManager | Default implementation of mm_it. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file DefaultMemoryManager. |
C-kern/ | Implementation file DefaultMemoryManager impl. |
Types | |
struct mm_impl_t | Exports mm_impl_t. |
Functions | |
test | |
unittest_memory_mm_mmimpl | Test default memory manager mm_impl_t. |
mm_impl_t | Default memory manager for allocating/freeing blocks of memory. |
initthread | |
interface_mmimpl | This function is called from <init_threadcontext>. |
lifetime | |
mmimpl_FREE | Static initializer. |
init_mmimpl | Initializes a new memory manager. |
free_mmimpl | Frees all memory managed by this manager. |
query | |
sizeallocated_mmimpl | Returns the size in bytes of all allocated memory blocks. |
allocate | |
malloc_mmimpl | Allocates new memory block. |
mresize_mmimpl | Allocates new memory or resizes already allocated memory. |
mfree_mmimpl | Frees the memory of an allocated memory block. |
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 DefaultMemoryManager.
Implementation file DefaultMemoryManager impl.
typedef struct mm_impl_t mm_impl_t
Exports mm_impl_t.
test | |
unittest_memory_mm_mmimpl | Test default memory manager mm_impl_t. |
int unittest_memory_mm_mmimpl( void )
Test default memory manager mm_impl_t.
struct mm_impl_t
Default memory manager for allocating/freeing blocks of memory.
initthread | |
interface_mmimpl | This function is called from <init_threadcontext>. |
lifetime | |
mmimpl_FREE | Static initializer. |
init_mmimpl | Initializes a new memory manager. |
free_mmimpl | Frees all memory managed by this manager. |
query | |
sizeallocated_mmimpl | Returns the size in bytes of all allocated memory blocks. |
allocate | |
malloc_mmimpl | Allocates new memory block. |
mresize_mmimpl | Allocates new memory or resizes already allocated memory. |
mfree_mmimpl | Frees the memory of an allocated memory block. |
struct mm_it * interface_mmimpl( void )
This function is called from <init_threadcontext>. Used to initialize interface of mm_t.
int malloc_mmimpl( mm_impl_t * mman, size_t size, /*out*/struct memblock_t * memblock )
Allocates new memory block.
On successful return the field memblock_t.size can be set to a larger value than provided in size to allow the memory manager for some internal optimization. To free a memory block it is enough to call mfree_mmimpl with the returned memblock. It is allowed to set memblock_t.size to the same value as provided in argument size.
int mresize_mmimpl( mm_impl_t * mman, size_t newsize, struct memblock_t * memblock )
Allocates new memory or resizes already allocated memory. Allocation is a special case in that it is a resize operation with the size and addr of parameter memblock_t set to 0.
Before calling this function make sure that memblock is either set to <memblock_FREE> or to a value returned by a previous call to malloc_mmimpl or this function.
On successful return the field memblock_t.size can be set to a larger value than provided in newsize to allow the memory manager for some internal optimization. To free a memory block it is enough to call mfree_mmimpl with the returned memblock. It is allowed to set memblock_t.size to the same value as provided in argument newsize.
The function table describing the interface to a memory manager.
struct mm_it
Exports mm_impl_t.
typedef struct mm_impl_t mm_impl_t
Default memory manager for allocating/freeing blocks of memory.
struct mm_impl_t
Test default memory manager mm_impl_t.
int unittest_memory_mm_mmimpl( void )
This function is called from init_threadcontext.
struct mm_it * interface_mmimpl( void )
Static initializer.
#define mmimpl_FREE { 0 }
Initializes a new memory manager.
int init_mmimpl( /*out*/mm_impl_t * mman )
Frees all memory managed by this manager.
int free_mmimpl( mm_impl_t * mman )
Returns the size in bytes of all allocated memory blocks.
size_t sizeallocated_mmimpl( mm_impl_t * mman )
Allocates new memory block.
int malloc_mmimpl( mm_impl_t * mman, size_t size, /*out*/struct memblock_t * memblock )
Allocates new memory or resizes already allocated memory.
int mresize_mmimpl( mm_impl_t * mman, size_t newsize, struct memblock_t * memblock )
Frees the memory of an allocated memory block.
int mfree_mmimpl( mm_impl_t * mman, struct memblock_t * memblock )
Uses iobj_DECLARE to declare interfaceable object.
iobj_DECLARE( mm_t, mm )
Size of memory in bytes addr points to.
size_t size
Describes memory block.
struct memblock_t