Fixed bug 2912528.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1414 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2009-12-11 15:55:08 +00:00
parent d980d7e3e4
commit f2c5dc67ea
1 changed files with 8 additions and 12 deletions

View File

@ -28,15 +28,8 @@
#if CH_USE_MEMCORE #if CH_USE_MEMCORE
#if CH_MEMCORE_SIZE == 0 static uint8_t *nextmem;
extern align_t __heap_base__; static uint8_t *endmem;
extern align_t __heap_end__;
#else
align_t buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / sizeof(align_t)];
#endif
static align_t *nextmem;
static align_t *endmem;
/** /**
* @brief Low level memory manager initialization. * @brief Low level memory manager initialization.
@ -45,11 +38,14 @@ static align_t *endmem;
*/ */
void core_init(void) { void core_init(void) {
#if CH_MEMCORE_SIZE == 0 #if CH_MEMCORE_SIZE == 0
extern uint8_t __heap_base__;
extern uint8_t __heap_end__;
nextmem = &__heap_base__; nextmem = &__heap_base__;
endmem = &__heap_end__; endmem = &__heap_end__;
#else #else
nextmem = &buffer[0]; static align_t buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / sizeof(align_t)];
endmem = &buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / sizeof(align_t)]; nextmem = (uint8_t *)&buffer[0];
endmem = (uint8_t *)&buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / sizeof(align_t)];
#endif #endif
} }
@ -87,7 +83,7 @@ void *chCoreAllocI(size_t size) {
void *p; void *p;
size = MEM_ALIGN_SIZE(size); size = MEM_ALIGN_SIZE(size);
if ((size_t)((uint8_t *)endmem - (uint8_t *)nextmem) < size) if ((size_t)(endmem - nextmem) < size)
return NULL; return NULL;
p = nextmem; p = nextmem;
nextmem += size; nextmem += size;