diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-18 21:40:25 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-18 21:40:25 -0700 |
commit | 7277c45c15d8b13db0326e03dff9e4b4c00ad5b5 (patch) | |
tree | d28affabfd459d582547a67d394c6fee249f6f8f | |
parent | abcd7ee5c09d7fbd26410b6f880e5534b0bbb51a (diff) | |
download | txr-7277c45c15d8b13db0326e03dff9e4b4c00ad5b5.tar.gz txr-7277c45c15d8b13db0326e03dff9e4b4c00ad5b5.tar.bz2 txr-7277c45c15d8b13db0326e03dff9e4b4c00ad5b5.zip |
ffi: eliminate trivial allocas in bitfield code.
* ffi.c (ffi_generic_sbit_put, ffi_generic_sbit_get,
ffi_generic_ubit_put, ffi_generic_ubit_get): Replace int-sized
alloca with declared int object.
-rw-r--r-- | ffi.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -1462,35 +1462,35 @@ static val ffi_ubit_get(struct txr_ffi_type *tft, mem_t *src, val self) static void ffi_generic_sbit_put(struct txr_ffi_type *tft, val n, mem_t *dst, val self) { - mem_t *tmp = coerce(mem_t *, zalloca(sizeof (int))); - memcpy(tmp, dst, tft->size); - ffi_sbit_put(tft, n, tmp, self); - memcpy(dst, tmp, tft->size); + int tmp = 0; + memcpy(&tmp, dst, tft->size); + ffi_sbit_put(tft, n, coerce(mem_t *, &tmp), self); + memcpy(dst, &tmp, tft->size); } static val ffi_generic_sbit_get(struct txr_ffi_type *tft, mem_t *src, val self) { - mem_t *tmp = coerce(mem_t *, zalloca(sizeof (int))); - memcpy(tmp, src, tft->size); - return ffi_sbit_get(tft, tmp, self); + int tmp = 0; + memcpy(&tmp, src, tft->size); + return ffi_sbit_get(tft, coerce(mem_t *, &tmp), self); } static void ffi_generic_ubit_put(struct txr_ffi_type *tft, val n, mem_t *dst, val self) { - mem_t *tmp = coerce(mem_t *, zalloca(sizeof (int))); - memcpy(tmp, dst, tft->size); - ffi_ubit_put(tft, n, tmp, self); - memcpy(dst, tmp, tft->size); + int tmp = 0; + memcpy(&tmp, dst, tft->size); + ffi_ubit_put(tft, n, coerce(mem_t *, &tmp), self); + memcpy(dst, coerce(mem_t *, &tmp), tft->size); } static val ffi_generic_ubit_get(struct txr_ffi_type *tft, mem_t *src, val self) { - mem_t *tmp = coerce(mem_t *, zalloca(sizeof (int))); - memcpy(tmp, src, tft->size); - return ffi_ubit_get(tft, tmp, self); + int tmp = 0; + memcpy(&tmp, src, tft->size); + return ffi_ubit_get(tft, coerce(mem_t *, &tmp), self); } static void ffi_bool_put(struct txr_ffi_type *tft, val truth, |