aboutsummaryrefslogtreecommitdiff
path: root/src/adlmidi_ptr.hpp
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2018-05-16 18:04:48 +0200
committerJP Cimalando <jpcima@users.noreply.github.com>2018-05-16 19:35:30 +0200
commit5574ad1dbe0195e13eae51b845385d4ed75c0990 (patch)
treea532268e1c7c310cd30dcbae8c69ce152e1fe958 /src/adlmidi_ptr.hpp
parent9b478615e7f0cd73c360fd289b05db52b5f730f1 (diff)
downloadlibADLMIDI-5574ad1dbe0195e13eae51b845385d4ed75c0990.tar.gz
libADLMIDI-5574ad1dbe0195e13eae51b845385d4ed75c0990.tar.bz2
libADLMIDI-5574ad1dbe0195e13eae51b845385d4ed75c0990.zip
fix a shared pointer bug which destroys a live counter
Diffstat (limited to 'src/adlmidi_ptr.hpp')
-rw-r--r--src/adlmidi_ptr.hpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/adlmidi_ptr.hpp b/src/adlmidi_ptr.hpp
index 7faacff..1e1a5f4 100644
--- a/src/adlmidi_ptr.hpp
+++ b/src/adlmidi_ptr.hpp
@@ -23,6 +23,9 @@
#ifndef ADLMIDI_PTR_HPP_THING
#define ADLMIDI_PTR_HPP_THING
+
+#include <stddef.h>
+
/*
Smart pointer for C heaps, created with malloc() call.
FAQ: Why not std::shared_ptr? Because of Android NDK now doesn't supports it
@@ -177,16 +180,13 @@ public:
if(m_p && --*m_counter == 0) {
DELETER del;
del(m_p);
- }
- m_p = p;
- if(!p) {
- if(m_counter) {
+ if(!p) {
delete m_counter;
m_counter = NULL;
}
}
- else
- {
+ m_p = p;
+ if(p) {
if(!m_counter)
m_counter = new size_t;
*m_counter = 1;