From c15f7d465feae4a66e9f4ee68b2d0fc6067dbeb0 Mon Sep 17 00:00:00 2001 From: jxh Date: Thu, 25 Mar 1999 08:45:13 +0000 Subject: Fix a big memory leak when failing to cache large objects. --- apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'apps') diff --git a/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp b/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp index 47ee7bf278b..fb7c9bb55e9 100644 --- a/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp +++ b/apps/JAWS/PROTOTYPE/JAWS/Cache_Manager_T.cpp @@ -5,8 +5,8 @@ #include "JAWS/Cache_Manager_T.h" #include "JAWS/Cache_Hash_T.h" -#include "JAWS/Cache_Heap_T.h" -#include "JAWS/Cache_List_T.h" + +class Cache_Manager; #include @@ -53,9 +53,9 @@ ACE_Cache_Manager this->factory_ = Object_Factory::instance (); ACE_NEW_MALLOC (this->hash_, - (Cache_Hash *) - this->allocator_->malloc (sizeof (Cache_Hash)), - Cache_Hash (alloc, hashsize)); + (ACE_CACHE_HASH *) + this->allocator_->malloc (sizeof (ACE_CACHE_HASH)), + ACE_CACHE_HASH (alloc, hashsize)); if (this->hash_ == 0) { @@ -206,7 +206,10 @@ ACE_Cache_Manager result = this->MAKE (data, size, obj); if (result == -1) { - cerr << "MAKE failed. Bummer!" << endl; + if (obj) + this->DROP_i (obj); + else + cerr << "MAKE failed. Bummer!" << endl; return -1; } @@ -360,6 +363,7 @@ ACE_Cache_Manager // The above is a little tricky to implement. Think about it // some more. cerr << "*** " << size << " is too large to cache" << endl; + obj = this->factory_->create (data, size); return -1; #endif /* 0 */ -- cgit v1.2.1