aboutsummaryrefslogtreecommitdiffstats
path: root/src/chmempools.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-11-27 19:38:03 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-11-27 19:38:03 +0000
commit4c4689df98554b3089d1dd66c60f92deab9d1603 (patch)
tree32ea6c8bf7fc61222debd9bfe3376bb5733507ae /src/chmempools.c
parent68a1ac21b8a7708cf6ff75391253e7746f18a9a1 (diff)
downloadChibiOS-4c4689df98554b3089d1dd66c60f92deab9d1603.tar.gz
ChibiOS-4c4689df98554b3089d1dd66c60f92deab9d1603.tar.bz2
ChibiOS-4c4689df98554b3089d1dd66c60f92deab9d1603.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@520 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chmempools.c')
-rw-r--r--src/chmempools.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/chmempools.c b/src/chmempools.c
index ae97648a4..dad37aeb4 100644
--- a/src/chmempools.c
+++ b/src/chmempools.c
@@ -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();
}