Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / MEM_SAP.cpp
blob6269849cc238907243160e713acc77f7b68dd996
1 #include "ace/MEM_SAP.h"
3 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
5 #if !defined (__ACE_INLINE__)
6 #include "ace/MEM_SAP.inl"
7 #endif /* __ACE_INLINE__ */
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_ALLOC_HOOK_DEFINE(ACE_MEM_SAP)
13 void
14 ACE_MEM_SAP::dump () const
16 #if defined (ACE_HAS_DUMP)
17 ACE_TRACE ("ACE_MEM_SAP::dump");
19 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
20 if (this->shm_malloc_ != 0)
21 this->shm_malloc_->dump ();
22 else
23 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_MEM_SAP uninitialized.\n")));
24 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
25 #endif /* ACE_HAS_DUMP */
28 ACE_MEM_SAP::ACE_MEM_SAP ()
29 : handle_ (ACE_INVALID_HANDLE),
30 shm_malloc_ (0)
32 // ACE_TRACE ("ACE_MEM_SAP::ACE_MEM_SAP");
35 ACE_MEM_SAP::~ACE_MEM_SAP ()
37 // ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
38 delete this->shm_malloc_;
41 int
42 ACE_MEM_SAP::fini ()
44 ACE_TRACE ("ACE_MEM_SAP::fini");
46 return this->close_shm_malloc ();
49 int
50 ACE_MEM_SAP::create_shm_malloc (const ACE_TCHAR *name,
51 MALLOC_OPTIONS *options)
53 ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
55 if (this->shm_malloc_ != 0)
56 return -1; // already initialized.
58 ACE_NEW_RETURN (this->shm_malloc_,
59 MALLOC_TYPE (name,
61 options),
62 -1);
64 if (this->shm_malloc_->bad () != 0)
66 this->shm_malloc_->remove (); // Cleanup OS resources
67 delete this->shm_malloc_;
68 this->shm_malloc_ = 0;
69 return -1;
72 return 0;
75 int
76 ACE_MEM_SAP::close_shm_malloc ()
78 ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
80 int retv = -1;
82 if (this->shm_malloc_ != 0)
83 if (this->shm_malloc_->release (1) == 0)
84 ACE_Process_Mutex::unlink (this->shm_malloc_->memory_pool ().
85 mmap ().filename ());
87 delete this->shm_malloc_;
88 this->shm_malloc_ = 0;
90 return retv;
93 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
95 ACE_END_VERSIONED_NAMESPACE_DECL