[riot-notifications] [RIOT] add a generic list and make lowpan.c use that list (#304)

Christian Mehlis notifications at github.com
Tue Nov 5 09:37:57 CET 2013


> +#define simple_list_remove(head, node)	_simple_list_remove((struct simple_list_elem**) head, (struct simple_list_elem*) node, 0)
> +#define simple_list_extract(head, node)	_simple_list_remove((struct simple_list_elem**) head, (struct simple_list_elem*) node, 1)
> +#define simple_list_clear(head)	_simple_list_clear((struct simple_list_elem**) head)
> +
> +#define simple_list_for_each(head, node)	for (node = head; node; node = node->next)
> +#define simple_list_for_each_safe(head, node, prev, skipped)	\
> +		for (skipped = 0, prev = 0, node = head; node; prev = (skipped ? prev : node), node = (skipped ? node : node->next), skipped = 0)
> +#define simple_list_for_each_remove(head, node, prev)	{	\
> +	if (!prev) {					\
> +		skipped = 1;				\
> +		*head = (*head)->next;		\
> +	} else							\
> +		prev->next = node->next;	\
> +	free(node);						\
> +	node = prev ? prev : *head;		\
> +	}

I think we don't want multi line defines, so all of these functions should go as normal c functions.

The rule of thumb:use define for function aliases, but if you have more than one command use a normal function

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/304/files#r7424239
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20131105/85755186/attachment.html>


More information about the notifications mailing list