@@ -105,22 +105,28 @@ class Pool {
105105template <typename T, bool Mutex>
106106T* Pool<T, Mutex>::allocate_pool(long count) {
107107 T* p{};
108- p = static_cast <T*>(
109- nrn_cacheline_calloc (reinterpret_cast <void **>(&p), count * subcount_, sizeof (T)));
110- printf (" %p allocate_pool: %p\n " , this , p);
108+ if (subcount_ > 1 ){
109+ p = static_cast <T*>(
110+ nrn_cacheline_calloc (reinterpret_cast <void **>(&p), count * subcount_, sizeof (T)));
111+ }else {
112+ p = new T[count];
113+ }
111114 return p;
112115}
113116
114117template <typename T, bool Mutex>
115118void Pool<T, Mutex>::deallocate_pool(T* p) {
116- free (p);
119+ if (subcount_ > 1 ){
120+ free (p);
121+ }else {
122+ delete [] p;
123+ }
117124}
118125
119126template <typename T, bool Mutex>
120127Pool<T, Mutex>::Pool(long count, long subcount)
121128 : count_(count)
122129 , subcount_(subcount) {
123- printf (" %p: count_: %ld, subcount_: %ld\n " , this , count, subcount);
124130 pool_ = allocate_pool (count_);
125131 pool_size_ = count_;
126132 freelist_.reserve (count_);
@@ -158,13 +164,11 @@ T* Pool<T, Mutex>::alloc() {
158164 freelist_.pop_back ();
159165 ++nget_;
160166 ++total_allocs_;
161- printf (" %p alloc: %p\n " , this , item);
162167 return item;
163168}
164169
165170template <typename T, bool Mutex>
166171void Pool<T, Mutex>::hpfree(T* item) {
167- printf (" %p hpfree: %p\n " , this , item);
168172 std::lock_guard<mutex_type> lock (mut_);
169173 assert (nget_ > 0 );
170174 freelist_.push_back (item);
0 commit comments