// $Id$ #ifndef ACE_FREE_LIST_C #define ACE_FREE_LIST_C #include "ace/Free_List.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #if !defined (__ACE_INLINE__) #include "ace/Free_List.i" #endif /* __ACE_INLINE__ */ ACE_RCSID(ace, Free_List, "$Id$") // Empty constructor template ACE_Free_List::~ACE_Free_List (void) { // Nothing } // Default constructor that takes in a preallocation number // (), a low and high water mark ( and ) and an // increment value () template ACE_Locked_Free_List::ACE_Locked_Free_List (int mode, size_t prealloc, size_t lwm, size_t hwm, size_t inc) : mode_ (mode), free_list_ (0), lwm_ (lwm), hwm_ (hwm), inc_ (inc), size_ (0) { this->alloc (prealloc); } // Destructor - removes all the elements from the free_list template ACE_Locked_Free_List::~ACE_Locked_Free_List (void) { if (this->mode_ != ACE_PURE_FREE_LIST) while (this->free_list_ != 0) { T *temp = this->free_list_; this->free_list_ = this->free_list_->get_next (); delete temp; } } // Allocates extra nodes for the freelist template void ACE_Locked_Free_List::alloc (size_t n) { for (; n > 0; n--) { T *temp; ACE_NEW (temp, T); temp->set_next (this->free_list_); this->free_list_ = temp; this->size_++; } } // Removes and frees nodes from the freelist. template void ACE_Locked_Free_List::dealloc (size_t n) { for (; this->free_list_ != 0 && n > 0; n--) { T *temp = this->free_list_; this->free_list_ = this->free_list_->get_next (); delete temp; this->size_--; } } #endif /* ACE_FREE_LIST_C */