From 99b4f4d6d6f18321489bae50f1762b29165f7de1 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 14 Mar 2023 12:50:27 +0100 Subject: irmd: Use buffer_t for piggybacked data Instead of passing a const void * and len, it now passes buffer_t to operations that send piggybacked data (flow_req_arr and flow_reply) and a buffer_t * for operations that send and receive piggybacked data (flow_alloc and flow_accept). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- include/ouroboros/utils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h index bd174149..f5f8610d 100644 --- a/include/ouroboros/utils.h +++ b/include/ouroboros/utils.h @@ -25,16 +25,20 @@ #include #include +#include #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define ABS(a) ((a) > 0 ? (a) : -(a)) +#define clrbuf(buf) do { memset(&(buf), 0, sizeof(buf)); } while (0); +#define freebuf(buf) do { free((buf).data); clrbuf(buf); } while (0); typedef struct { uint8_t * data; size_t len; } buffer_t; + /* * Returns the number of characters a uint would * need when represented as a string -- cgit v1.2.3