diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-13 05:10:42 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-13 05:10:42 +0000 |
commit | 63e99a0f37d40cf72fbc6e0123e0489f8d6cf790 (patch) | |
tree | 8739a610453c80368a53ce38dd96ae39340a3efc /ace/Malloc_T.i | |
parent | cd3962290ff3c24020e0c461bc666ce39d20af74 (diff) | |
download | ATCD-63e99a0f37d40cf72fbc6e0123e0489f8d6cf790.tar.gz |
Added ACE_Cached_Mem_Pool_Node_T and ACE_Cached_Allocator.
Diffstat (limited to 'ace/Malloc_T.i')
-rw-r--r-- | ace/Malloc_T.i | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ace/Malloc_T.i b/ace/Malloc_T.i index 56f815d8bf2..8b1193b3206 100644 --- a/ace/Malloc_T.i +++ b/ace/Malloc_T.i @@ -3,6 +3,24 @@ // Malloc_T.i +template <class T, class LOCK> void * +ACE_Cached_Allocator<T, LOCK>::malloc (size_t nbytes) +{ + // Check if size requested fits within pre-determined size. + if (nbytes > sizeof (T)) + return NULL; + + // addr() call is really not absolutely necessary because of the way + // ACE_Cached_Mem_Pool_Node_T's internal structure arranged. + return this->free_list_.remove ()->addr (); +} + +template <class T, class LOCK> void +ACE_Cached_Allocator<T, LOCK>::free (void * ptr) +{ + this->free_list_.add ((ACE_Cached_Mem_Pool_Node_T<T> *) ptr) ; +} + template <class MALLOC> ACE_INLINE void * ACE_Allocator_Adapter<MALLOC>::malloc (size_t nbytes) { |