From 030e87185a97d81176a7f74ff4fe418c8e6f58ae Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 6 Sep 2013 17:20:04 +0200 Subject: [PATCH] implement COAP_MALLOC_TYPE on lwip the approach fits very well with the lwippools, and only requires minimal changes there. --- resource.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/resource.c b/resource.c index d1266c62..36d20e8a 100644 --- a/resource.c +++ b/resource.c @@ -13,10 +13,21 @@ #include "subscribe.h" #ifdef WITH_LWIP -#include -#endif +#include "utlist.h" +/* mem.h is only needed for the string free calls for + * COAP_ATTR_FLAGS_RELEASE_NAME / COAP_ATTR_FLAGS_RELEASE_VALUE / + * COAP_RESOURCE_FLAGS_RELEASE_URI. not sure what those lines should actually + * do on lwip. */ +#include "mem.h" -#ifndef WITH_CONTIKI +#include + +#define COAP_MALLOC_TYPE(Type) \ + ((coap_##Type##_t *)memp_malloc(MEMP_COAP_##Type)) +#define COAP_FREE_TYPE(Type, Object) memp_free(MEMP_COAP_##Type, Object) + +#endif +#ifdef WITH_POSIX #include "utlist.h" #include "mem.h" @@ -24,7 +35,8 @@ ((coap_##Type##_t *)coap_malloc(sizeof(coap_##Type##_t))) #define COAP_FREE_TYPE(Type, Object) coap_free(Object) -#else /* WITH_CONTIKI */ +#endif /* WITH_POSIX */ +#ifdef WITH_CONTIKI #include "memb.h" MEMB(resource_storage, coap_resource_t, COAP_MAX_RESOURCES);