diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-10-17 09:21:59 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-10-17 09:21:59 +0000 |
commit | 34fd822f84d409fa649934251fae01994de7888b (patch) | |
tree | 095f9c11f7aa2e5f2c0b451c1ba15b08d76f5c47 /os/kernel/src | |
parent | a7cfbdaf10a03aa10236958bdba38479b301fc4f (diff) | |
download | ChibiOS-34fd822f84d409fa649934251fae01994de7888b.tar.gz ChibiOS-34fd822f84d409fa649934251fae01994de7888b.tar.bz2 ChibiOS-34fd822f84d409fa649934251fae01994de7888b.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1226 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src')
-rw-r--r-- | os/kernel/src/chmemcore.c | 4 | ||||
-rw-r--r-- | os/kernel/src/chmempools.c | 23 |
2 files changed, 20 insertions, 7 deletions
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c index 00e04a2d6..7177fe432 100644 --- a/os/kernel/src/chmemcore.c +++ b/os/kernel/src/chmemcore.c @@ -60,7 +60,7 @@ void core_init(void) { * <code>sizeof(align_t)</code>.
*
*
- * @param[in] the size of the block to be allocated
+ * @param[in] size the size of the block to be allocated
* @return A pointer to the allocated memory block.
* @retval NULL allocation failed, core memory exhausted. */
@@ -79,7 +79,7 @@ void *chCoreAlloc(size_t size) { * type @p align_t so it is not possible to allocate less than
* <code>sizeof(align_t)</code>.
*
- * @param[in] the size of the block to be allocated.
+ * @param[in] size the size of the block to be allocated.
* @return A pointer to the allocated memory block.
* @retval NULL allocation failed, core memory exhausted.
*/
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c index a8d7da818..76ef39b58 100644 --- a/os/kernel/src/chmempools.c +++ b/os/kernel/src/chmempools.c @@ -32,14 +32,20 @@ *
* @param[out] mp pointer to a @p MemoryPool structure
* @param[in] size the size of the objects contained in this memory pool,
- * the minimum accepted size is the size of a pointer to void
+ * the minimum accepted size is the size of a pointer to void.
+ *
+ * @note The size is internally aligned to be a multiple of the @p align_t
+ * type size.
*/
void chPoolInit(MemoryPool *mp, size_t size) {
chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
mp->mp_next = NULL;
- mp->mp_object_size = size;
+ mp->mp_object_size = MEM_ALIGN_SIZE(size);
+#if CH_USE_MEMCORE
+ mp->mp_usecore = FALSE;
+#endif
}
/**
@@ -56,7 +62,10 @@ void *chPoolAllocI(MemoryPool *mp) { if ((objp = mp->mp_next) != NULL)
mp->mp_next = mp->mp_next->ph_next;
-
+#if CH_USE_MEMCORE
+ else if (mp->mp_usecore)
+ objp = chCoreAllocI(mp->mp_object_size);
+#endif
return objp;
}
@@ -81,13 +90,17 @@ void *chPoolAlloc(MemoryPool *mp) { *
* @param[in] mp pointer to a @p MemoryPool structure
* @param[in] 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
+ *
+ * @note The object is assumed to be of the right size for the specified
* memory pool.
+ * @note The object is assumed to be memory aligned to the size of @p align_t
+ * type.
*/
void chPoolFreeI(MemoryPool *mp, void *objp) {
struct pool_header *php = objp;
- chDbgCheck((mp != NULL) && (objp != NULL), "chPoolFreeI");
+ chDbgCheck((mp != NULL) && (objp != NULL) && MEM_IS_ALIGNED(objp),
+ "chPoolFreeI");
php->ph_next = mp->mp_next;
mp->mp_next = php;
|