git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@415 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2008-08-29 13:08:11 +00:00
parent ff6163a049
commit 5eff277ef4
1 changed files with 6 additions and 4 deletions

View File

@ -45,7 +45,7 @@ static struct {
struct header free; /* Guaranteed to be not adjacent to the heap */ struct header free; /* Guaranteed to be not adjacent to the heap */
#if defined(CH_USE_MUTEXES) #if defined(CH_USE_MUTEXES)
#define H_LOCK() chMtxLock(&heap.hmtx) #define H_LOCK() chMtxLock(&heap.hmtx)
#define H_UNLOCK() chMtxLock(&heap.hmtx) #define H_UNLOCK() chMtxUnlock()
Mutex hmtx; Mutex hmtx;
#elif defined(CH_USE_SEMAPHORES) #elif defined(CH_USE_SEMAPHORES)
#define H_LOCK() chSemWait(&heap.hsem) #define H_LOCK() chSemWait(&heap.hsem)
@ -120,7 +120,7 @@ void *chHeapAlloc(size_t size) {
else { else {
/* Block bigger enough, must split it */ /* Block bigger enough, must split it */
fp = (void *)((char *)(hp) + sizeof(struct header) + size); fp = (void *)((char *)(hp) + sizeof(struct header) + size);
fp->h_next = qp->h_next; fp->h_next = hp->h_next;
fp->h_size = hp->h_size - sizeof(struct header) - size; fp->h_size = hp->h_size - sizeof(struct header) - size;
qp->h_next = fp; qp->h_next = fp;
hp->h_size = size; hp->h_size = size;
@ -137,7 +137,9 @@ void *chHeapAlloc(size_t size) {
return NULL; return NULL;
} }
#define LIMIT(p) (struct header *)((char *)(p) + (p)->h_size) #define LIMIT(p) (struct header *)((char *)(p) + \
sizeof(struct header) + \
(p)->h_size)
/** /**
* Frees a previously allocated memory block. * Frees a previously allocated memory block.