summaryrefslogtreecommitdiff
path: root/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/utils/mir_buffer.h11
-rw-r--r--Plugins/utils/mir_memory.cpp10
-rw-r--r--Plugins/utils/mir_memory.h21
3 files changed, 34 insertions, 8 deletions
diff --git a/Plugins/utils/mir_buffer.h b/Plugins/utils/mir_buffer.h
index 1bcdab3..4a5f012 100644
--- a/Plugins/utils/mir_buffer.h
+++ b/Plugins/utils/mir_buffer.h
@@ -157,9 +157,9 @@ class Buffer
{
size = total + 256 - total % 256;
if (str == NULL)
- str = (T *) malloc(size * sizeof(T));
+ str = (T *) mir_alloc(size * sizeof(T));
else
- str = (T *) realloc(str, size * sizeof(T));
+ str = (T *) mir_realloc(str, size * sizeof(T));
}
}
@@ -167,7 +167,7 @@ class Buffer
{
if (str != NULL)
{
- ::free(str);
+ mir_free(str);
str = NULL;
len = size = 0;
}
@@ -181,7 +181,7 @@ class Buffer
void append(T app)
{
- alloc(len + 1);
+ alloc(len + 1 + 1);
str[len] = app;
len++;
@@ -190,7 +190,7 @@ class Buffer
void appendn(size_t n, T app)
{
- alloc(len + n);
+ alloc(len + n + 1);
for(; n > 0; n--)
{
@@ -346,7 +346,6 @@ class Buffer
str[i] = str[len-i-1];
str[len-i-1] = tmp;
}
- pack();
}
T *appender(size_t appLen)
diff --git a/Plugins/utils/mir_memory.cpp b/Plugins/utils/mir_memory.cpp
index cea960b..615f3dc 100644
--- a/Plugins/utils/mir_memory.cpp
+++ b/Plugins/utils/mir_memory.cpp
@@ -18,9 +18,9 @@ Boston, MA 02111-1307, USA.
*/
+#define MIRANDA_VER 0x0700
#include "mir_memory.h"
-#define MIRANDA_VER 0x0700
#include <newpluginapi.h>
#include <m_system.h>
@@ -35,6 +35,14 @@ void init_mir_malloc()
}
+BOOL mir_is_unicode()
+{
+ char ver[1024];
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(ver), (LPARAM) ver);
+ return strstr(ver, "Unicode") != NULL;
+}
+
+
void * mir_alloc0(size_t size)
{
void * ptr = mir_alloc(size);
diff --git a/Plugins/utils/mir_memory.h b/Plugins/utils/mir_memory.h
index ef2a0d4..52440ae 100644
--- a/Plugins/utils/mir_memory.h
+++ b/Plugins/utils/mir_memory.h
@@ -28,12 +28,23 @@ Boston, MA 02111-1307, USA.
void init_mir_malloc();
+BOOL mir_is_unicode();
+
+
void * mir_alloc0(size_t size);
int strcmpnull(char *str1, char *str2);
int strcmpnullW(WCHAR *str1, WCHAR *str2);
-#ifdef _UNICODE
+#ifdef UNICODE
+
+#define CHECK_VERSION(_NAME_) \
+ if (!mir_is_unicode()) \
+ { \
+ MessageBox(NULL, _T("Your Miranda is ansi. You have to install ansi ") _T(_NAME_), \
+ _T(_NAME_), MB_OK | MB_ICONERROR); \
+ return -1; \
+ }
# define lstrcmpnull strcmpnullW
@@ -48,6 +59,14 @@ int strcmpnullW(WCHAR *str1, WCHAR *str2);
#else
+#define CHECK_VERSION(_NAME_) \
+ if (mir_is_unicode()) \
+ { \
+ MessageBox(NULL, _T("Your Miranda is unicode. You have to install unicode ") _T(_NAME_), \
+ _T(_NAME_), MB_OK | MB_ICONERROR); \
+ return -1; \
+ }
+
# define lstrcmpnull strcmpnull
#define INPLACE_CHAR_TO_TCHAR(_new_var_, _size_, _old_var_) \