Allow allocate in user-space with malloc

This commit is contained in:
Vadim Vetrov 2024-09-14 20:37:19 +03:00
parent d93763ac44
commit 5e28fe83c2
No known key found for this signature in database
GPG Key ID: E8A308689D7A73A5

View File

@ -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 <stdlib.h>
#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)