aboutsummaryrefslogtreecommitdiff
path: root/shared/bin.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-25 16:30:21 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-25 16:30:21 +0200
commit9cd83d662849fe72c83038a018107d9bbf5c2398 (patch)
treeaeae2f79b63f09eebbb72e56bee0facbad34fb1d /shared/bin.c
parent4f0718caefa7f7a1baf02997fec0b448d0d6615a (diff)
WIP serial parsing
Diffstat (limited to 'shared/bin.c')
-rw-r--r--shared/bin.c8
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;
+}