summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-09 21:00:27 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-09 21:00:27 +0300
commit6872262b3619b07418092be5a7689c8c195282a2 (patch)
treea666a85b8f5eafb34a9dc17d76114573b512fdce /src/mir_core
parent8da4a50fd56cd6b2ffc84c307cb6385ba6e1dd9a (diff)
MShareable - dirty crutch instead of using std::shared_ptr, which is incompatible with Miranda's core
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/mir_core.vcxproj3
-rw-r--r--src/mir_core/mir_core.vcxproj.filters3
-rw-r--r--src/mir_core/src/Windows/shareable.cpp45
-rw-r--r--src/mir_core/src/mir_core.def5
-rw-r--r--src/mir_core/src/mir_core64.def5
5 files changed, 61 insertions, 0 deletions
diff --git a/src/mir_core/mir_core.vcxproj b/src/mir_core/mir_core.vcxproj
index feea5de395..5926603bf0 100644
--- a/src/mir_core/mir_core.vcxproj
+++ b/src/mir_core/mir_core.vcxproj
@@ -167,6 +167,9 @@
<ClCompile Include="src\Windows\resizer.cpp">
<PrecompiledHeaderFile>../stdafx.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="src\Windows\shareable.cpp">
+ <PrecompiledHeaderFile>../stdafx.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="src\Windows\subclass.cpp">
<PrecompiledHeaderFile>../stdafx.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/mir_core/mir_core.vcxproj.filters b/src/mir_core/mir_core.vcxproj.filters
index 3a4bd83508..1b936d0685 100644
--- a/src/mir_core/mir_core.vcxproj.filters
+++ b/src/mir_core/mir_core.vcxproj.filters
@@ -182,6 +182,9 @@
<ClCompile Include="src\Windows\diatheme.cpp">
<Filter>Source Files\Windows</Filter>
</ClCompile>
+ <ClCompile Include="src\Windows\shareable.cpp">
+ <Filter>Source Files\Windows</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\stdafx.h">
diff --git a/src/mir_core/src/Windows/shareable.cpp b/src/mir_core/src/Windows/shareable.cpp
new file mode 100644
index 0000000000..35dd6c2832
--- /dev/null
+++ b/src/mir_core/src/Windows/shareable.cpp
@@ -0,0 +1,45 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org),
+Copyright (c) 2000-12 Miranda IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "../stdafx.h"
+
+MShareable::MShareable() :
+ m_iUseCount(1)
+{
+}
+
+MShareable::~MShareable()
+{
+}
+
+void MShareable::Acquire()
+{
+ ::InterlockedIncrement(&m_iUseCount);
+}
+
+void MShareable::Release()
+{
+ if (::InterlockedDecrement(&m_iUseCount) == 0)
+ delete this;
+}
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index c0a444d6ec..af4fbd0c30 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1553,3 +1553,8 @@ db_event_updateId @1772
?SetPageOwner@CCtrlPages@@QAEXXZ @1774 NONAME
?db_event_setJson@@YGHIPBDPAUDBVARIANT@@@Z @1775 NONAME
?CreatePage@CCtrlPages@@AAEXPAVCDlgBase@@@Z @1776 NONAME
+??0MShareable@@IAE@XZ @1777 NONAME
+??1MShareable@@MAE@XZ @1778 NONAME
+??_7MShareable@@6B@ @1779 NONAME
+?Acquire@MShareable@@QAEXXZ @1780 NONAME
+?Release@MShareable@@QAEXXZ @1781 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index b68c98f66d..c071152ab3 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1553,3 +1553,8 @@ db_event_updateId @1772
?SetPageOwner@CCtrlPages@@QEAAXXZ @1774 NONAME
?db_event_setJson@@YAHIPEBDPEAUDBVARIANT@@@Z @1775 NONAME
?CreatePage@CCtrlPages@@AEAAXPEAVCDlgBase@@@Z @1776 NONAME
+??0MShareable@@IEAA@XZ @1777 NONAME
+??1MShareable@@MEAA@XZ @1778 NONAME
+??_7MShareable@@6B@ @1779 NONAME
+?Acquire@MShareable@@QEAAXXZ @1780 NONAME
+?Release@MShareable@@QEAAXXZ @1781 NONAME