From f3d98c9a2b03318ec4f0aa182034273f8226afb4 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 4 Jun 2013 10:43:47 +0200 Subject: [PATCH] allow having a resource list instead of a hash this brings O(n) lookup time for resources, but allows removing dynamic memory management --- config.h.lwip | 2 ++ resource.c | 19 ++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/config.h.lwip b/config.h.lwip index 5c1b02a0..39c5e849 100644 --- a/config.h.lwip +++ b/config.h.lwip @@ -22,4 +22,6 @@ known to be needed -- but it's optional here (the lwIP port will also run if you choose to malloc everything and undef this again) */ #define COAP_STATIC_RESOURCES +#define COAP_RESOURCES_NOHASH + #endif /* _CONFIG_H_ */ diff --git a/resource.c b/resource.c index a00ba13a..367508f0 100644 --- a/resource.c +++ b/resource.c @@ -589,20 +589,7 @@ coap_delete_observer(coap_resource_t *resource, const coap_address_t *observer, if (s) { list_remove(resource->subscribers, s); -<<<<<<< HEAD COAP_FREE_TYPE(subscription,s); -======= - /* FIXME: notify observer that its subscription has been removed */ -#ifdef WITH_LWIP - memp_free(MEMP_COAP_SUBSCRIBER, s); -#endif -#ifdef WITH_POSIX - coap_free(s); -#endif -#ifdef WITH_CONTIKI - memb_free(&subscription_storage, s); -#endif /* WITH_CONTIKI */ ->>>>>>> use lwip pools for observations } } @@ -689,11 +676,17 @@ coap_check_notify(coap_context_t *context) { #ifdef COAP_RESOURCES_NOHASH LL_FOREACH(context->resources, r) { #else +<<<<<<< HEAD coap_resource_t *tmp; HASH_ITER(hh, context->resources, r, tmp) { #endif coap_notify_observers(context, r); } +======= + HASH_ITER(hh, context->resources, r, tmp) { +#endif + if (r->observable && r->dirty && r->subscribers) { +>>>>>>> allow having a resource list instead of a hash #else /* WITH_CONTIKI */ int i;