From f02bad80e9ca6af0abd2d58d5ebaf6c3f83d9bae Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 15 May 2025 21:57:32 -0700 Subject: ffi: take advantage of string_utf8_from_buf. * ffi.c (ffi_char_array_get, ffi_zchar_array_get): Use newly added string_utf8_from_buf rather than utf8_dup_from_buf followed by string_own. --- ffi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ffi.c b/ffi.c index aebd8234..fe55e642 100644 --- a/ffi.c +++ b/ffi.c @@ -2870,8 +2870,7 @@ static val ffi_char_array_get(struct txr_ffi_type *tft, mem_t *src, } else if (nelem == 0) { return null_string; } else { - wchar_t *wch = utf8_dup_from_buf(chptr, nelem); - return string_own(wch); + return string_utf8_from_buf(chptr, nelem); } } @@ -2906,8 +2905,7 @@ static val ffi_zchar_array_get(struct txr_ffi_type *tft, mem_t *src, } else if (memchr(chptr, 0, nelem)) { return string_utf8(chptr); } else { - wchar_t *wch = utf8_dup_from_buf(chptr, nelem); - return string_own(wch); + return string_utf8_from_buf(chptr, nelem); } } -- cgit v1.2.3