1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */ 2 3 /* coap_list.c -- CoAP list structures 4 * 5 * Copyright (C) 2010,2011,2015 Olaf Bergmann <bergmann@tzi.org> 6 * 7 * This file is part of the CoAP library libcoap. Please see README for terms of 8 * use. 9 */ 10 11 /* #include "coap_config.h" */ 12 13 #include <stdio.h> 14 #include <string.h> 15 16 #include "debug.h" 17 #include "mem.h" 18 #include "coap_list.h" 19 20 21 int coap_insert(coap_list_t ** head,coap_list_t * node)22coap_insert(coap_list_t **head, coap_list_t *node) { 23 if (!node) { 24 coap_log(LOG_WARNING, "cannot create option Proxy-Uri\n"); 25 } else { 26 /* must append at the list end to avoid re-ordering of 27 * options during sort */ 28 LL_APPEND((*head), node); 29 } 30 31 return node != NULL; 32 } 33 34 int coap_delete(coap_list_t * node)35coap_delete(coap_list_t *node) { 36 if (node) { 37 coap_free(node); 38 } 39 return 1; 40 } 41 42 void coap_delete_list(coap_list_t * queue)43coap_delete_list(coap_list_t *queue) { 44 coap_list_t *elt, *tmp; 45 46 if (!queue) 47 return; 48 49 LL_FOREACH_SAFE(queue, elt, tmp) { 50 coap_delete(elt); 51 } 52 } 53 54