27 #include <oc_stdlib.h> 36 #define _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________ 40 void * _malloc( oC_UInt_t Size ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags )
42 void * address =
NULL;
44 Allocator_t allocator = oC_ProcessMan_GetCurrentAllocator();
56 bool _free(
void * Address , AllocationFlags_t Flags )
63 void * _rawmalloc( oC_UInt_t Size ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags)
65 void * address =
NULL;
67 oC_Process_t process = oC_ProcessMan_GetCurrentProcess();
69 if(oC_Process_IsCorrect(process))
71 oC_HeapMap_t map = oC_Process_GetHeapMap(process);
84 bool _rawfree(
void * Address , oC_UInt_t Size)
86 bool released =
false;
88 oC_Process_t process = oC_ProcessMan_GetCurrentProcess();
90 if(oC_Process_IsCorrect(process))
92 oC_HeapMap_t map = oC_Process_GetHeapMap(process);
105 void * _kmalloc( oC_UInt_t Size ,
Allocator_t Allocator ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags , oC_UInt_t Alignment )
112 bool _kfree(
void * Address , AllocationFlags_t Flags )
119 void * _krawmalloc( oC_HeapMap_t Map , oC_UInt_t Size ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags )
126 bool _krawfree( oC_HeapMap_t Map ,
void * Address , oC_UInt_t Size )
133 void * _smartalloc( oC_UInt_t Size ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags )
135 void * address =
NULL;
137 oC_UInt_t realRawAllocationSize = Size + ((Size/8) + (((Size%8) > 0) ? 1 : 0));
140 if(realAllocationSize >= realRawAllocationSize)
142 address = _rawmalloc(Size,Function,LineNumber,Flags);
146 address = _malloc(Size,Function,LineNumber,Flags);
153 bool _smartfree(
void * Address , oC_UInt_t Size , AllocationFlags_t Flags )
155 bool released = _rawfree(Address,Size);
159 released = _free(Address,Flags);
167 void * _ksmartalloc( oC_UInt_t Size ,
Allocator_t Allocator ,
const char * Function, uint32_t LineNumber , AllocationFlags_t Flags)
169 void * address = _smartalloc(Size,Function,LineNumber,Flags);
173 address = _kmalloc(Size,Allocator,Function,LineNumber,Flags,0);
181 bool _ksmartfree(
void * Address , oC_UInt_t Size , AllocationFlags_t Flags)
183 bool released = _smartfree(Address,Size,Flags);
185 if(released ==
false)
187 released = _kfree(Address,Flags);
195 bool isram(
const void * Address )
202 bool isrom(
const void * Address )
209 bool isbufferinram(
const void * Buffer , oC_UInt_t Size )
211 return isram(Buffer) && isram(&((uint8_t*)Buffer)[Size-1]);
216 bool isbufferinrom(
const void * Buffer , oC_UInt_t Size )
218 return isrom(Buffer) && isrom(&((uint8_t*)Buffer)[Size-1]);
223 bool isaddresscorrect(
const void * Address )
228 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________ bool oC_MemMan_IsRamAddress(const void *Address)
checks if address is in ram section
identifier for allocations
void * oC_MemMan_RawAllocate(oC_HeapMap_t Map, oC_UInt_t Size, const char *Function, uint32_t LineNumber, AllocationFlags_t Flags)
allow to allocate memory in heap map
The file with interface for process manager.
bool oC_MemMan_RawFree(oC_HeapMap_t Map, void *Address, oC_UInt_t Size)
release memory in heap map
void * oC_MemMan_Allocate(oC_UInt_t Size, Allocator_t Allocator, const char *Function, uint32_t LineNumber, AllocationFlags_t Flags, oC_UInt_t Alignment)
allocates memory on heap
oC_UInt_t oC_MemMan_GetAllocationBlockSize(void)
returns size of block needed for allocation
bool oC_MemMan_IsAddressCorrect(const void *Address)
checks if address is correct - in RAM or in FLASH
bool oC_MemMan_Free(void *Address, AllocationFlags_t Flags)
release allocated memory
The file with memory manager interface.
static const oC_Allocator_t Allocator
bool oC_MemMan_IsFlashAddress(const void *Address)
checks if address is placed in the flash section
#define NULL
pointer to a zero