summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/memory.cpp35
-rw-r--r--src/mir_core/mir_core.def1
2 files changed, 24 insertions, 12 deletions
diff --git a/src/mir_core/memory.cpp b/src/mir_core/memory.cpp
index 0ed432a610..b8bf481aad 100644
--- a/src/mir_core/memory.cpp
+++ b/src/mir_core/memory.cpp
@@ -142,10 +142,10 @@ MIR_C_CORE_DLL(void) mir_free(void* ptr)
/******************************************************************************/
-MIR_CORE_DLL(char*) mir_strdup(const char* str)
+MIR_CORE_DLL(char*) mir_strdup(const char *str)
{
if (str != NULL) {
- char* p = (char*)mir_alloc(strlen(str)+1);
+ char *p = (char*)mir_alloc(strlen(str)+1);
if (p)
strcpy(p, str);
return p;
@@ -153,13 +153,24 @@ MIR_CORE_DLL(char*) mir_strdup(const char* str)
return NULL;
}
+MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR *str)
+{
+ if (str != NULL) {
+ WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
+ if (p)
+ wcscpy(p, str);
+ return p;
+ }
+ return NULL;
+}
+
/******************************************************************************/
-MIR_CORE_DLL(char*) mir_strndup(const char* str, size_t len)
+MIR_CORE_DLL(char*) mir_strndup(const char *str, size_t len)
{
if (str != NULL && len != 0) {
- char* p = (char*)mir_alloc(len + 1);
- if ( !p) {
+ char *p = (char*)mir_alloc(len+1);
+ if (p) {
memcpy(p, str, len);
p[ len ] = 0;
}
@@ -168,14 +179,14 @@ MIR_CORE_DLL(char*) mir_strndup(const char* str, size_t len)
return NULL;
}
-/******************************************************************************/
-
-MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR* str)
+MIR_CORE_DLL(WCHAR*) mir_wstrndup(const WCHAR *str, size_t len)
{
- if (str != NULL) {
- WCHAR* p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
- if (p)
- wcscpy(p, str);
+ if (str != NULL && len != 0) {
+ WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1));
+ if (p) {
+ memcpy(p, str, sizeof(WCHAR)*len);
+ p[ len ] = 0;
+ }
return p;
}
return NULL;
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index a5978b9ddb..c124c559e5 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -139,3 +139,4 @@ Icon_RegisterT @136
mir_subclassWindow @137
mir_callNextSubclass @138
KillModuleSubclassing @139
+mir_wstrndup @140