From ef74fd8c4f0f7b56c7c7416072acb25b6789c8c7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 26 Apr 2017 06:46:31 -0700 Subject: ffi: no memcpy for string pointers. ffi.c (ffi_str_put, ffi_str_get, ffi_wstr_put, ffi_wstr_get): Use assignment instead of memcpy to move the string pointer to and from the buffer. --- ffi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ffi.c b/ffi.c index 00143b87..911cf605 100644 --- a/ffi.c +++ b/ffi.c @@ -556,19 +556,19 @@ static void ffi_str_put(struct txr_ffi_type *tft, val s, mem_t *dst, val self) { const wchar_t *ws = c_str(s); - char *u8s = utf8_dup_to(ws); + const char *u8s = utf8_dup_to(ws); free(tft->buf); tft->buf = coerce(mem_t *, u8s); tft->in = ffi_freeing_in; - memcpy(dst, &u8s, sizeof u8s); + *coerce(const char **, dst) = u8s; } static val ffi_str_get(struct txr_ffi_type *tft, mem_t *src, val self) { (void) tft; (void) self; - char *p; - memcpy(&p, src, sizeof p); + const char *p; + p = *coerce(const char **, src); return string_utf8(p); } @@ -576,15 +576,14 @@ static void ffi_wstr_put(struct txr_ffi_type *tft, val s, mem_t *dst, val self) { const wchar_t *ws = c_str(s); - memcpy(dst, &ws, sizeof ws); + *coerce(const wchar_t **, dst) = ws; } static val ffi_wstr_get(struct txr_ffi_type *tft, mem_t *src, val self) { (void) tft; (void) self; - wchar_t *p; - memcpy(&p, src, sizeof p); + const wchar_t *p = *coerce(wchar_t **, src); return string(p); } -- cgit v1.2.3