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

This commit is contained in:
gdisirio 2008-11-27 19:38:03 +00:00
parent 68a1ac21b8
commit 4c4689df98
3 changed files with 34 additions and 11 deletions

View File

@ -75,6 +75,8 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*** 0.8.2 ***
- FIX: Duplicated sections in the documentation removed.
- NEW: Added chPoolAllocI() and chPoolFreeI() APIs in order to allow the use
of memory pools from interrupt handlers and timer callbacks.
*** 0.8.1 ***
- FIX: Fixed a regression in version 0.8.0, the configuration switch

View File

@ -46,16 +46,28 @@ void chPoolInit(MemoryPool *mp, size_t size) {
* @return The pointer to the allocated object.
* @retval NULL if pool is empty.
*/
void *chPoolAlloc(MemoryPool *mp) {
void *chPoolAllocI(MemoryPool *mp) {
void *objp;
chDbgAssert(mp != NULL, "chpools.c, chPoolAlloc()");
chSysLock();
chDbgAssert(mp != NULL, "chmempools.c, chPoolAllocI()");
if ((objp = mp->mp_next) != NULL)
mp->mp_next = mp->mp_next->ph_next;
return objp;
}
/**
* Allocates an object from a memory pool.
* @param mp pointer to a \p MemoryPool structure
* @return The pointer to the allocated object.
* @retval NULL if pool is empty.
*/
void *chPoolAlloc(MemoryPool *mp) {
void *objp;
chSysLock();
objp = chPoolAllocI(mp);
chSysUnlock();
return objp;
}
@ -67,17 +79,27 @@ void *chPoolAlloc(MemoryPool *mp) {
* @note the object is assumed to be of the right size for the specified
* memory pool.
*/
void chPoolFree(MemoryPool *mp, void *objp) {
void chPoolFreeI(MemoryPool *mp, void *objp) {
struct pool_header *php = objp;
chDbgAssert((mp != NULL) && (objp != NULL),
"chpools.c, chPoolFree()");
chSysLock();
"chmempools.c, chPoolFreeI()");
php->ph_next = mp->mp_next;
mp->mp_next = php;
}
/**
* Releases (or adds) an object into (to) a memory pool.
* @param mp pointer to a \p MemoryPool structure
* @param objp the pointer to the object to be released or added
* @note the object is assumed to be of the right size for the specified
* memory pool.
*/
void chPoolFree(MemoryPool *mp, void *objp) {
chSysLock();
chPoolFreeI(mp, objp);
chSysUnlock();
}

View File

@ -43,11 +43,10 @@ typedef struct {
extern "C" {
#endif
void chPoolInit(MemoryPool *mp, size_t size);
void *chPoolAllocI(MemoryPool *mp);
void *chPoolAlloc(MemoryPool *mp);
void chPoolFreeI(MemoryPool *mp, void *objp);
void chPoolFree(MemoryPool *mp, void *objp);
#ifdef CH_USE_HEAP
void chPoolRelease(MemoryPool *mp);
#endif
#ifdef __cplusplus
}
#endif