pool: use size_t for allocated sizes

This commit is contained in:
Danny Robson 2014-12-31 19:07:25 +11:00
parent 1c009b9602
commit 36a80c33a9
2 changed files with 15 additions and 6 deletions

View File

@ -22,6 +22,8 @@
#include "nocopy.hpp" #include "nocopy.hpp"
#include <cstdlib>
namespace util { namespace util {
template <typename T> template <typename T>
class pool : public nocopy { class pool : public nocopy {
@ -33,18 +35,25 @@ namespace util {
node *m_head; node *m_head;
node *m_next; node *m_next;
unsigned int m_capacity; size_t m_capacity;
public: public:
pool (unsigned int _capacity); pool (unsigned int _capacity);
~pool (); ~pool ();
unsigned int capacity (void) const; // Data management
template <typename ...Args> template <typename ...Args>
T* acquire (Args&... args); T* acquire (Args&... args);
void release (T *data); void release (T *data);
size_t capacity (void) const;
// Indexing
size_t index (const T*) const;
T& operator[] (size_t idx);
const T& operator[] (size_t idx) const;
}; };
} }

View File

@ -55,7 +55,7 @@ namespace util {
template <typename T> template <typename T>
unsigned int size_t
pool<T>::capacity (void) const pool<T>::capacity (void) const
{ return m_capacity; } { return m_capacity; }