aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-09-05 15:48:43 +0100
committerGitHub <noreply@github.com>2022-09-05 15:48:43 +0100
commit12687a63f4e43593eb51ecef36acf9bb9d86fa73 (patch)
treef076b4cb48231c7fbfcac7f4cf9f6f831380eedb /core/sys
parentd699d872d974509c2cdbe5a1d0913f51e9335d69 (diff)
parent87094ef96c5c85b728bd48fd7f9b95d6c89206b9 (diff)
Merge pull request #1951 from IanLilleyT/wstring_allocation
smaller allocation for non-null-terminated wstring
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/windows/util.odin6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin
index 2bdd72ed2..36383a2c7 100644
--- a/core/sys/windows/util.odin
+++ b/core/sys/windows/util.odin
@@ -73,10 +73,10 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
// If N == -1 the call to WideCharToMultiByte assume the wide string is null terminated
// and will scan it to find the first null terminated character. The resulting string will
- // also null terminated.
+ // also be null terminated.
// If N != -1 it assumes the wide string is not null terminated and the resulting string
- // will not be null terminated, we therefore have to force it to be null terminated manually.
- text := make([]byte, n+1 if N != -1 else n) or_return
+ // will not be null terminated.
+ text := make([]byte, n) or_return
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil)
if n1 == 0 {