Commit 71b06a89 authored by David Reid's avatar David Reid

Add some wchar_t string functions.

This is in preparation for some work coming to the upcoming resource
manager.
parent 045fd9e7
...@@ -7074,6 +7074,35 @@ MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src) ...@@ -7074,6 +7074,35 @@ MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
return 34; return 34;
} }
MA_API int ma_wcscpy_s(wchar_t* dst, size_t dstSizeInBytes, const wchar_t* src)
{
size_t i;
if (dst == 0) {
return 22;
}
if (dstSizeInBytes == 0) {
return 34;
}
if (src == 0) {
dst[0] = '\0';
return 22;
}
for (i = 0; i < dstSizeInBytes && src[i] != '\0'; ++i) {
dst[i] = src[i];
}
if (i < dstSizeInBytes) {
dst[i] = '\0';
return 0;
}
dst[0] = '\0';
return 34;
}
MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count) MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
{ {
size_t maxcount; size_t maxcount;
...@@ -7318,6 +7347,19 @@ MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAll ...@@ -7318,6 +7347,19 @@ MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAll
return dst; return dst;
} }
MA_API wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks)
{
size_t sz = wcslen(src)+1;
wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks);
if (dst == NULL) {
return NULL;
}
ma_wcscpy_s(dst, sz, src);
return dst;
}
#include <errno.h> #include <errno.h>
static ma_result ma_result_from_errno(int e) static ma_result ma_result_from_errno(int e)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment