00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <OPENR/OShmPtrBase.h>
00023 #include <cstring>
00024
00025 OShmPtrBase::OShmPtrBase()
00026 {
00027 init();
00028 }
00029
00030 OShmPtrBase::OShmPtrBase(const OShmPtrBase& rhs)
00031 {
00032 pointee_ = rhs.RCRPtr();
00033 pointee_->AddReference();
00034 }
00035
00036 OShmPtrBase::OShmPtrBase(RCRegion *p)
00037 {
00038 pointee_ = p;
00039 pointee_->AddReference();
00040 }
00041
00042 OShmPtrBase::~OShmPtrBase()
00043 {
00044 Deallocate();
00045 }
00046
00047 void OShmPtrBase::Deallocate()
00048 {
00049 if (pointee_) {
00050 pointee_->RemoveReference();
00051 init();
00052 }
00053 }
00054
00055 const OShmPtrBase& OShmPtrBase::operator=(const OShmPtrBase& rhs)
00056 {
00057 Deallocate();
00058 pointee_ = rhs.RCRPtr();
00059 pointee_->AddReference();
00060 return *this;
00061 }
00062
00063 void OShmPtrBase::init()
00064 {
00065 pointee_ = NULL;
00066 }
00067
00068
00069
00070 void memcpy(void* s1, const OShmPtrBase& s2, size_t size)
00071 {
00072 memcpy(s1, s2.Base(), size);
00073 }