aboutsummaryrefslogtreecommitdiffstats
path: root/os/various
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-07 09:53:34 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-07 09:53:34 +0000
commitfe7aa77ae0686a8f42d2b7fdb86582de9e02b0d5 (patch)
treec827352c5740923bf6a26efc54508f3969751cb1 /os/various
parent25002cf195cea44cd4d741358e25b114c162f4ac (diff)
downloadChibiOS-fe7aa77ae0686a8f42d2b7fdb86582de9e02b0d5.tar.gz
ChibiOS-fe7aa77ae0686a8f42d2b7fdb86582de9e02b0d5.tar.bz2
ChibiOS-fe7aa77ae0686a8f42d2b7fdb86582de9e02b0d5.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5038 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/various')
-rw-r--r--os/various/cpp_wrappers/ch.hpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/os/various/cpp_wrappers/ch.hpp b/os/various/cpp_wrappers/ch.hpp
index e92fbcc9e..d565cbb77 100644
--- a/os/various/cpp_wrappers/ch.hpp
+++ b/os/various/cpp_wrappers/ch.hpp
@@ -2128,23 +2128,29 @@ namespace chibios_rt {
};
/*------------------------------------------------------------------------*
- * chibios_rt::MemoryPool *
+ * chibios_rt::ObjectsPool *
*------------------------------------------------------------------------*/
/**
- * @brief Template class encapsulating a mailbox and its elements.
+ * @brief Template class encapsulating a memory pool and its elements.
*/
template<class T, size_t N>
- class MemoryPoolBuffer : public MemoryPool {
+ class ObjectsPool : public MemoryPool {
private:
- T pool_buf[N];
+ /* The buffer is declared as an array of pointers to void for two
+ reasons:
+ 1) The objects must be properly aligned to hold a pointer as
+ first field.
+ 2) There is no need to invoke constructors for object that are
+ into the pool.*/
+ void *pool_buf[(N * sizeof (T)) / sizeof (void *)];
public:
/**
- * @brief MemoryPoolBuffer constructor.
+ * @brief ObjectsPool constructor.
*
* @init
*/
- MemoryPoolBuffer(void) : MemoryPool(sizeof (T), NULL) {
+ ObjectsPool(void) : MemoryPool(sizeof (T), NULL) {
loadArray(pool_buf, N);
}