mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-07 10:12:53 +03:00
use lwip memp pools for allocating coap_queue_t
This commit is contained in:
1 parent
e74a4c1690
commit
2a6f04dd16
2 files changed
+32
-4
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
/** Memory pool definitions for the libcoap when used with lwIP (which has its
|
||||
* own mechanism for quickly allocating chunks of data with known sizes). Has
|
||||
* to be findable by lwIP (ie. an #include <lwippools.h> must either directly
|
||||
* include this or include something more generic which includes this), and
|
||||
* MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */
|
||||
|
||||
#include <net.h>
|
||||
|
||||
#ifndef MEMP_NUM_COAPNODE
|
||||
#define MEMP_NUM_COAPNODE 4
|
||||
#endif
|
||||
|
||||
LWIP_MEMPOOL(COAP_NODE, MEMP_NUM_COAPNODE, sizeof(coap_queue_t), "COAP_NODE")
|
||||
@@ -40,9 +40,7 @@
|
||||
#include "encode.h"
|
||||
#include "net.h"
|
||||
|
||||
#if defined(WITH_POSIX) || defined(WITH_LWIP)
|
||||
|
||||
/* FIXME: in lwip, we'll use pbufs later */
|
||||
#if defined(WITH_POSIX)
|
||||
|
||||
time_t clock_offset;
|
||||
|
||||
@@ -55,7 +53,24 @@ static inline void
|
||||
coap_free_node(coap_queue_t *node) {
|
||||
coap_free(node);
|
||||
}
|
||||
#endif /* WITH_POSIX || WITH_LWIP */
|
||||
#endif /* WITH_POSIX */
|
||||
#ifdef WITH_LWIP
|
||||
|
||||
#include <lwip/memp.h>
|
||||
|
||||
time_t clock_offset; /* FIXME timing is currently ignored */
|
||||
|
||||
static inline coap_queue_t *
|
||||
coap_malloc_node() {
|
||||
return (coap_queue_t *)memp_malloc(MEMP_COAP_NODE);
|
||||
}
|
||||
|
||||
static inline void
|
||||
coap_free_node(coap_queue_t *node) {
|
||||
memp_free(MEMP_COAP_NODE, node);
|
||||
}
|
||||
|
||||
#endif /* WITH_LWIP */
|
||||
#ifdef WITH_CONTIKI
|
||||
# ifndef DEBUG
|
||||
# define DEBUG DEBUG_PRINT
|
||||
|
||||
Reference in new issue
Block a user