Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit be63b0f

Browse files
[[ Bug 14259 ]] Implements MCStringCreateWithWStringAndRelease
1 parent 27a0048 commit be63b0f

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

engine/src/dskw32.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,8 +3491,8 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
34913491
DWORD dwFileNameLen = GetModuleFileNameW(NULL, wcFileNameBuf, MAX_PATH+1);
34923492

34933493
MCAutoStringRef t_path;
3494-
MCStringCreateWithWStringAndRelease(wcFileNameBuf, &t_path);
3495-
return PathFromNative(*t_path, r_path);
3494+
MCStringCreateWithWStringAndRelease((unichar_t*)wcFileNameBuf, &t_path);
3495+
return PathFromNative(*t_path, r_path);
34963496
}
34973497

34983498
virtual bool PathToNative(MCStringRef p_path, MCStringRef& r_native)

libfoundation/src/foundation-string.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ bool MCStringCreateWithWString(const unichar_t *p_wstring, MCStringRef& r_string
380380
return MCStringCreateWithChars(p_wstring, t_length, r_string);
381381
}
382382

383+
bool MCStringCreateWithWStringAndRelease(unichar_t* p_wstring, MCStringRef& r_string)
384+
{
385+
if (MCStringCreateWithWString(p_wstring, r_string))
386+
{
387+
free(p_wstring);
388+
return true;
389+
}
390+
391+
return false;
392+
}
393+
383394
bool MCStringCreateWithNativeChars(const char_t *p_chars, uindex_t p_char_count, MCStringRef& r_string)
384395
{
385396
bool t_success;

0 commit comments

Comments
 (0)