diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-26 06:46:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-26 06:46:31 -0700 |
commit | ef74fd8c4f0f7b56c7c7416072acb25b6789c8c7 (patch) | |
tree | aa6309bb8d3c8d204ed0c933dd39c9ae67adf43b /ffi.c | |
parent | be83bc717db0375e19431fe38c0490ff1a9e40ec (diff) | |
download | txr-ef74fd8c4f0f7b56c7c7416072acb25b6789c8c7.tar.gz txr-ef74fd8c4f0f7b56c7c7416072acb25b6789c8c7.tar.bz2 txr-ef74fd8c4f0f7b56c7c7416072acb25b6789c8c7.zip |
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.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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); } |