00001
00002
00003 #include "ace/MEM_SAP.h"
00004
00005 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00006
00007 #if !defined (__ACE_INLINE__)
00008 #include "ace/MEM_SAP.inl"
00009 #endif
00010
00011 ACE_RCSID(ace, MEM_SAP, "MEM_SAP.cpp,v 4.21 2006/04/19 19:13:09 jwillemsen Exp")
00012
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
00016
00017 void
00018 ACE_MEM_SAP::dump (void) const
00019 {
00020 #if defined (ACE_HAS_DUMP)
00021 ACE_TRACE ("ACE_MEM_SAP::dump");
00022
00023 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00024 if (this->shm_malloc_ != 0)
00025 this->shm_malloc_->dump ();
00026 else
00027 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_MEM_SAP uninitialized.\n")));
00028 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00029 #endif
00030 }
00031
00032 ACE_MEM_SAP::ACE_MEM_SAP (void)
00033 : handle_ (ACE_INVALID_HANDLE),
00034 shm_malloc_ (0)
00035 {
00036
00037 }
00038
00039 ACE_MEM_SAP::~ACE_MEM_SAP (void)
00040 {
00041
00042 delete this->shm_malloc_;
00043 }
00044
00045 int
00046 ACE_MEM_SAP::fini ()
00047 {
00048 ACE_TRACE ("ACE_MEM_SAP::fini");
00049
00050 return this->close_shm_malloc ();
00051 }
00052
00053 int
00054 ACE_MEM_SAP::create_shm_malloc (const ACE_TCHAR *name,
00055 MALLOC_OPTIONS *options)
00056 {
00057 ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
00058
00059 if (this->shm_malloc_ != 0)
00060 return -1;
00061
00062 ACE_NEW_RETURN (this->shm_malloc_,
00063 MALLOC_TYPE (name,
00064 0,
00065 options),
00066 -1);
00067
00068 if (this->shm_malloc_->bad () != 0)
00069 {
00070 this->shm_malloc_->remove ();
00071 delete this->shm_malloc_;
00072 this->shm_malloc_ = 0;
00073 return -1;
00074 }
00075
00076 return 0;
00077 }
00078
00079 int
00080 ACE_MEM_SAP::close_shm_malloc (void)
00081 {
00082 ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
00083
00084 int retv = -1;
00085
00086 if (this->shm_malloc_ != 0)
00087 this->shm_malloc_->release (1);
00088
00089 delete this->shm_malloc_;
00090 this->shm_malloc_ = 0;
00091
00092 return retv;
00093 }
00094
00095 #endif
00096
00097 ACE_END_VERSIONED_NAMESPACE_DECL