From 5e28fe83c21ceae9c6a9dffc39d412b2b28f54b0 Mon Sep 17 00:00:00 2001 From: Vadim Vetrov Date: Sat, 14 Sep 2024 20:37:19 +0300 Subject: [PATCH] Allow allocate in user-space with malloc --- types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types.h b/types.h index 23cac9f..81b3b8e 100644 --- a/types.h +++ b/types.h @@ -96,6 +96,11 @@ typedef __u64 uint64_t; #define NETBUF_ALLOC(buf, buf_len) __u8* buf = kmalloc(buf_len, GFP_ATOMIC); #define NETBUF_CHECK(buf) ((buf) != NULL) #define NETBUF_FREE(buf) kfree(buf); +#elif defined(ALLOC_MALLOC) +#include +#define NETBUF_ALLOC(buf, buf_len) __u8* buf = malloc(buf_len); +#define NETBUF_CHECK(buf) ((buf) != NULL) +#define NETBUF_FREE(buf) free(buf); #else #define NETBUF_ALLOC(buf, buf_len) __u8 buf[buf_len]; #define NETBUF_CHECK(buf) (1)