blob: b5bd15ffd855559b42ce22266d31d407c526e00e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
--- libvmime-0.7.1.orig/vmime/utility/smartPtr.hpp 2005-05-19 19:17:17.000000000 +0200
+++ libvmime-0.7.1.patched/vmime/utility/smartPtr.hpp 2009-05-13 15:21:53.276875219 +0200
@@ -20,6 +20,9 @@
#ifndef VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
#define VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
+// non-portable, but atleast not an abi change
+#include <pthread.h>
+static pthread_mutex_t mapLock = PTHREAD_MUTEX_INITIALIZER;
namespace vmime {
namespace utility {
@@ -108,8 +111,10 @@
{
if (m_data->refCount == 1)
{
+ pthread_mutex_lock(&mapLock);
typename MapType::iterator it = sm_map.find(m_data->ptr);
if (it != sm_map.end()) sm_map.erase(it);
+ pthread_mutex_unlock(&mapLock);
delete (m_data->ptr);
delete (m_data);
@@ -127,6 +132,8 @@
{
detach();
+ pthread_mutex_lock(&mapLock);
+
typename MapType::iterator it = sm_map.find(p);
if (it != sm_map.end())
@@ -141,6 +148,7 @@
sm_map.insert(typename MapType::value_type(p, m_data));
}
+ pthread_mutex_unlock(&mapLock);
}
void attach(const smart_ptr <T>& p)
|