diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-20 09:07:32 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-20 09:07:32 +0000 |
commit | 121b80ba3be4318689cf5fd988a8ff0d6d0a5ead (patch) | |
tree | d3a2bc2b4515a357c7bb77ffb2b17a75cb20e56f /src/core | |
parent | 33401f05553ebe71d59fc3f271fbd6d7609529ee (diff) |
not used file removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@13709 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/memory.cpp | 285 |
1 files changed, 0 insertions, 285 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp deleted file mode 100644 index 890ff84647..0000000000 --- a/src/core/memory.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://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 "commonheaders.h"
-
-#define BLOCK_ALLOCED 0xABBABABA
-#define BLOCK_FREED 0xDEADBEEF
-
-static int CheckBlock(void* blk)
-{
- int result = FALSE;
- char* p = (char*)blk - sizeof(DWORD)*2;
- DWORD size, *b, *e;
-
- __try
- {
- size = *(DWORD*)p;
- b = (DWORD*)&p[ sizeof(DWORD) ];
- e = (DWORD*)&p[ sizeof(DWORD)*2 + size ];
-
- if (*b != BLOCK_ALLOCED || *e != BLOCK_ALLOCED)
- {
- if (*b == BLOCK_FREED && *e == BLOCK_FREED)
- OutputDebugStringA("memory block is already deleted\n");
- else
- OutputDebugStringA("memory block is corrupted\n");
- #if defined(_DEBUG)
- DebugBreak();
- #endif
- }
- else result = TRUE;
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- OutputDebugStringA("access violation during checking memory block\n");
- #if defined(_DEBUG)
- DebugBreak();
- #endif
- }
-
- return result;
-}
-
-/******************************************************************************/
-
-void* mir_alloc(size_t size)
-{
- if (size == 0)
- return NULL;
-
- char *p = (char*)malloc(size + sizeof(DWORD)* 3);
- if (p == NULL) {
- OutputDebugStringA("memory overflow\n");
- #if defined(_DEBUG)
- DebugBreak();
- #endif
- return NULL;
- }
-
- *(DWORD*)p = (DWORD)size;
- *(DWORD*)&p[sizeof(DWORD)] = BLOCK_ALLOCED;
- *(DWORD*)&p[size + sizeof(DWORD)*2] = BLOCK_ALLOCED;
- return p + sizeof(DWORD)* 2;
-}
-
-/******************************************************************************/
-
-void* mir_calloc(size_t size)
-{
- void* p = mir_alloc(size);
- if (p != NULL)
- memset(p, 0, size);
- return p;
-}
-
-/******************************************************************************/
-
-void* mir_realloc(void* ptr, size_t size)
-{
- char *p;
-
- if (ptr != NULL) {
- if (!CheckBlock(ptr))
- return NULL;
- p = (char*)ptr - sizeof(DWORD)*2;
- }
- else p = NULL;
-
- p = (char*)realloc(p, size + sizeof(DWORD)*3);
- if (p == NULL) {
- OutputDebugStringA("memory overflow\n");
- #if defined(_DEBUG)
- DebugBreak();
- #endif
- return NULL;
- }
-
- *(DWORD*)p = (DWORD)size;
- *(DWORD*)&p[sizeof(DWORD)] = BLOCK_ALLOCED;
- *(DWORD*)&p[size + sizeof(DWORD)*2] = BLOCK_ALLOCED;
- return p + sizeof(DWORD)*2;
-}
-
-/******************************************************************************/
-
-void mir_free(void* ptr)
-{
- char* p;
- DWORD size;
-
- if (ptr == NULL)
- return;
- if (!CheckBlock(ptr))
- return;
-
- p = (char*)ptr - sizeof(DWORD)*2;
- size = *(DWORD*)p;
-
- *(DWORD*)&p[sizeof(DWORD)] = BLOCK_FREED;
- *(DWORD*)&p[size + sizeof(DWORD)*2] = BLOCK_FREED;
- free(p);
-}
-
-/******************************************************************************/
-
-char* mir_strdup(const char *str)
-{
- if (str == NULL)
- return NULL;
-
- char *p = (char*)mir_alloc(strlen(str)+1);
- if (p)
- strcpy(p, str);
- return p;
-}
-
-WCHAR* mir_wstrdup(const WCHAR *str)
-{
- if (str == NULL)
- return NULL;
-
- WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
- if (p)
- wcscpy(p, str);
- return p;
-}
-
-/******************************************************************************/
-
-char* mir_strndup(const char *str, size_t len)
-{
- if (str == NULL || len == 0)
- return NULL;
-
- char *p = (char*)mir_alloc(len+1);
- if (p) {
- memcpy(p, str, len);
- p[len] = 0;
- }
- return p;
-}
-
-WCHAR* mir_wstrndup(const WCHAR *str, size_t len)
-{
- if (str == NULL || len == 0)
- return NULL;
-
- WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1));
- if (p) {
- memcpy(p, str, sizeof(WCHAR)*len);
- p[len] = 0;
- }
- return p;
-}
-
-/******************************************************************************/
-
-int mir_snprintf(char *buffer, size_t count, const char* fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
- int len = _vsnprintf(buffer, count-1, fmt, va);
- va_end(va);
- buffer[count-1] = 0;
- return len;
-}
-
-/******************************************************************************/
-
-int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
- int len = _vsntprintf(buffer, count-1, fmt, va);
- va_end(va);
- buffer[count-1] = 0;
- return len;
-}
-
-/******************************************************************************/
-
-int mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va)
-{
- int len = _vsnprintf(buffer, count-1, fmt, va);
- buffer[count-1] = 0;
- return len;
-}
-
-/******************************************************************************/
-
-int mir_vsnwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, va_list va)
-{
- int len = _vsntprintf(buffer, count-1, fmt, va);
- buffer[count-1] = 0;
- return len;
-}
-
-/******************************************************************************/
-
-wchar_t* mir_a2u_cp(const char* src, int codepage)
-{
- if (src == NULL)
- return NULL;
-
- int cbLen = MultiByteToWideChar(codepage, 0, src, -1, NULL, 0);
- wchar_t* result = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen+1));
- if (result == NULL)
- return NULL;
-
- MultiByteToWideChar(codepage, 0, src, -1, result, cbLen);
- result[cbLen] = 0;
- return result;
-}
-
-/******************************************************************************/
-
-wchar_t* mir_a2u(const char* src)
-{
- return mir_a2u_cp(src, Langpack_GetDefaultCodePage());
-}
-
-/******************************************************************************/
-
-char* mir_u2a_cp(const wchar_t* src, int codepage)
-{
- if (src == NULL)
- return NULL;
-
- int cbLen = WideCharToMultiByte(codepage, 0, src, -1, NULL, 0, NULL, NULL);
- char* result = (char*)mir_alloc(cbLen+1);
- if (result == NULL)
- return NULL;
-
- WideCharToMultiByte(codepage, 0, src, -1, result, cbLen, NULL, NULL);
- result[cbLen] = 0;
- return result;
-}
-
-/******************************************************************************/
-
-char* mir_u2a(const wchar_t* src)
-{
- return mir_u2a_cp(src, Langpack_GetDefaultCodePage());
-}
|