aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/fs/fatfs/fatfs_fsimpl.cpp4
-rw-r--r--os/fs/fatfs/fatfs_fsimpl.hpp4
-rw-r--r--os/various/cpp_wrappers/ch.hpp18
3 files changed, 16 insertions, 10 deletions
diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp
index c10c1a89f..c2981aea4 100644
--- a/os/fs/fatfs/fatfs_fsimpl.cpp
+++ b/os/fs/fatfs/fatfs_fsimpl.cpp
@@ -107,8 +107,8 @@ namespace chibios_fatfs {
/*------------------------------------------------------------------------*
* chibios_fatfs::FatFSFilesPool *
*------------------------------------------------------------------------*/
- FatFSFilesPool::FatFSFilesPool(void) : MemoryPoolBuffer<FatFSFileWrapper,
- FATFS_MAX_FILES>() {
+ FatFSFilesPool::FatFSFilesPool(void) : ObjectsPool<FatFSFileWrapper,
+ FATFS_MAX_FILES>() {
}
diff --git a/os/fs/fatfs/fatfs_fsimpl.hpp b/os/fs/fatfs/fatfs_fsimpl.hpp
index 2ab7fc4b0..5ee1ea601 100644
--- a/os/fs/fatfs/fatfs_fsimpl.hpp
+++ b/os/fs/fatfs/fatfs_fsimpl.hpp
@@ -92,8 +92,8 @@ namespace chibios_fatfs {
/**
* @brief Class of memory pool of @p FatFSFileWrapper objects.
*/
- class FatFSFilesPool : public MemoryPoolBuffer<FatFSFileWrapper,
- FATFS_MAX_FILES> {
+ class FatFSFilesPool : public ObjectsPool<FatFSFileWrapper,
+ FATFS_MAX_FILES> {
public:
FatFSFilesPool(void);
};
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);
}