Skip to content

Instantly share code, notes, and snippets.

@bagobor
Created April 17, 2012 13:22
Show Gist options
  • Save bagobor/2405942 to your computer and use it in GitHub Desktop.
Save bagobor/2405942 to your computer and use it in GitHub Desktop.
externals/gli/core/shared_array.inl | 33 +++++++--------------------------
1 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/externals/gli/core/shared_array.inl b/externals/gli/core/shared_array.inl
index 74edbb4..c76b8a9 100644
--- a/externals/gli/core/shared_array.inl
+++ b/externals/gli/core/shared_array.inl
@@ -23,16 +23,15 @@ namespace gli
{
this->Counter = SharedArray.Counter;
this->Pointer = SharedArray.Pointer;
- (*this->Counter)++;
+ if (this->Counter)
+ (*this->Counter)++;
}
template <typename T>
- shared_array<T>::shared_array
- (
- T * Pointer
- )
+ shared_array<T>::shared_array ( T * ptr ) : Pointer(0), Counter(0)
{
- this->reset(Pointer);
+ if (ptr)
+ this->reset(ptr);
}
template <typename T>
@@ -60,6 +59,8 @@ namespace gli
template <typename T>
void shared_array<T>::reset(T * Pointer)
{
+ this->reset();
+
this->Counter = new int;
this->Pointer = Pointer;
*this->Counter = 1;
@@ -80,26 +81,6 @@ namespace gli
return *this;
}
- //template <typename T>
- //shared_array<T> & shared_array<T>::operator=(T * Pointer)
- //{
- // if(this->Pointer)
- // {
- // (*this->Counter)--;
- // if(*this->Counter <= 0)
- // {
- // delete this->Counter;
- // delete[] this->Pointer;
- // }
- // }
-
- // this->Counter = new int;
- // this->Pointer = this->Pointer;
- // (*this->Counter) = 1;
-
- // return *this;
- //}
-
template <typename T>
bool shared_array<T>::operator==(shared_array<T> const & SharedArray) const
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment