summaryrefslogtreecommitdiffstats
path: root/src/libs/7zip/unix/CPP/Common/MyWindows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/7zip/unix/CPP/Common/MyWindows.cpp')
-rw-r--r--src/libs/7zip/unix/CPP/Common/MyWindows.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libs/7zip/unix/CPP/Common/MyWindows.cpp b/src/libs/7zip/unix/CPP/Common/MyWindows.cpp
index 4037d5ea3..9acddc974 100644
--- a/src/libs/7zip/unix/CPP/Common/MyWindows.cpp
+++ b/src/libs/7zip/unix/CPP/Common/MyWindows.cpp
@@ -5,16 +5,16 @@
#ifndef _WIN32
#include "MyWindows.h"
-#include "Types.h"
+#include "MyTypes.h"
#include <stdlib.h> /* FIXED <malloc.h> */
static inline void *AllocateForBSTR(size_t cb) { return ::malloc(cb); }
static inline void FreeForBSTR(void *pv) { ::free(pv);}
static UINT MyStringLen(const wchar_t *s)
-{
+{
UINT i;
- for (i = 0; s[i] != '\0'; i++) {}
+ for (i = 0; s[i] != '\0'; i++);
return i;
}
@@ -35,6 +35,21 @@ BSTR SysAllocStringByteLen(LPCSTR psz, UINT len)
return (BSTR)bstr;
}
+BSTR WINAPI SysAllocStringLen(const OLECHAR *sz, unsigned int numChars) // FIXME - code
+{
+ UINT len = (numChars + 1) * sizeof(OLECHAR);
+ void *p = AllocateForBSTR(len + sizeof(UINT));
+ if (p == 0)
+ return 0;
+ memset(p,0,len + sizeof(UINT));
+ *(UINT *)p = numChars * sizeof(OLECHAR); // FIXED
+ void * bstr = (void *)((UINT *)p + 1);
+ if (sz) memmove(bstr, sz, numChars * sizeof(OLECHAR)); // sz does not always have "wchar_t" alignment.
+
+ return (BSTR)bstr;
+}
+
+
BSTR SysAllocString(const OLECHAR *sz)
{
if (sz == 0)
@@ -84,7 +99,7 @@ HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src)
return res;
if (src->vt == VT_BSTR)
{
- dest->bstrVal = SysAllocStringByteLen((LPCSTR)src->bstrVal,
+ dest->bstrVal = SysAllocStringByteLen((LPCSTR)src->bstrVal,
SysStringByteLen(src->bstrVal));
if (dest->bstrVal == 0)
return E_OUTOFMEMORY;