GitHub Actions: Try MSVC builds with /std:c++17 and 20
[ACE_TAO.git] / ACE / ace / MEM_SAP.cpp
blob4386c0ca719a0d36f6952cf9b01e7828027c5531
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__ */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_ALLOC_HOOK_DEFINE(ACE_MEM_SAP)
15 void
16 ACE_MEM_SAP::dump (void) const
18 #if defined (ACE_HAS_DUMP)
19 ACE_TRACE ("ACE_MEM_SAP::dump");
21 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
22 if (this->shm_malloc_ != 0)
23 this->shm_malloc_->dump ();
24 else
25 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_MEM_SAP uninitialized.\n")));
26 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
27 #endif /* ACE_HAS_DUMP */
30 ACE_MEM_SAP::ACE_MEM_SAP (void)
31 : handle_ (ACE_INVALID_HANDLE),
32 shm_malloc_ (0)
34 // ACE_TRACE ("ACE_MEM_SAP::ACE_MEM_SAP");
37 ACE_MEM_SAP::~ACE_MEM_SAP (void)
39 // ACE_TRACE ("ACE_MEM_SAP::~ACE_MEM_SAP");
40 delete this->shm_malloc_;
43 int
44 ACE_MEM_SAP::fini ()
46 ACE_TRACE ("ACE_MEM_SAP::fini");
48 return this->close_shm_malloc ();
51 int
52 ACE_MEM_SAP::create_shm_malloc (const ACE_TCHAR *name,
53 MALLOC_OPTIONS *options)
55 ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
57 if (this->shm_malloc_ != 0)
58 return -1; // already initialized.
60 ACE_NEW_RETURN (this->shm_malloc_,
61 MALLOC_TYPE (name,
63 options),
64 -1);
66 if (this->shm_malloc_->bad () != 0)
68 this->shm_malloc_->remove (); // Cleanup OS resources
69 delete this->shm_malloc_;
70 this->shm_malloc_ = 0;
71 return -1;
74 return 0;
77 int
78 ACE_MEM_SAP::close_shm_malloc (void)
80 ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
82 int retv = -1;
84 if (this->shm_malloc_ != 0)
85 if (this->shm_malloc_->release (1) == 0)
86 ACE_Process_Mutex::unlink (this->shm_malloc_->memory_pool ().
87 mmap ().filename ());
89 delete this->shm_malloc_;
90 this->shm_malloc_ = 0;
92 return retv;
95 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
97 ACE_END_VERSIONED_NAMESPACE_DECL