diff options
Diffstat (limited to 'shared/bin.c')
-rw-r--r-- | shared/bin.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/bin.c b/shared/bin.c index a2c91a4..fc6e14b 100644 --- a/shared/bin.c +++ b/shared/bin.c @@ -1,4 +1,5 @@ #include <stdlib.h> +#include <memory.h> #include "bin.h" @@ -62,3 +63,10 @@ uint16_t w2_bin_hton16(uint16_t h16) { uint32_t w2_bin_ntoh32(uint32_t n32) { return w2_bin_hton32(n32); } uint16_t w2_bin_ntoh16(uint16_t n16) { return w2_bin_hton16(n16); } + +w2_s_bin *w2_bin_s_alloc(uint16_t bytes, uint8_t *data) { + w2_s_bin* temp = malloc(sizeof(w2_s_bin) + sizeof(uint8_t) * bytes); + temp->bytes = bytes; + memcpy(&temp->data, data, bytes); + return temp; +} |