* mcgarvey@eng.utah.edu
*/
-#ifndef __LIST_H__
-#define __LIST_H__
+#ifndef _LIST_H_
+#define _LIST_H_
#include "common.h"
* Add a value to the list. It will become the first item.
* This is a O(1) operation.
*/
-__fast__
+INLINE_MAYBE
void list_push2(list_t** l, void* value, void (*destructor)(void*))
{
list_t* n = (list_t*)mem_alloc(sizeof(list_t));
/*
* Add a value to the list with no destructor set.
*/
-__fast__
+INLINE_MAYBE
void list_push(list_t** l, void* value)
{
- list_push2(l, value, 0);
+ list_push2(l, value, NULL);
}
/*
* Create a new list with a single value.
*/
-__fast__
+INLINE_MAYBE
list_t* list_new2(void* value, void (*destructor)(void*))
{
list_t* l = NULL;
/*
* Create a new list with a single value without a destructor set.
*/
-__fast__
+INLINE_MAYBE
list_t* list_new(void* value)
{
list_t* l = NULL;
* will be used to destroy the value.
* This is a O(1) operation.
*/
-__fast__
+INLINE_MAYBE
void list_pop(list_t** l)
{
list_t* n = (*l)->link;
* Destroy the list, freeing up all of its memory.
* This is a O(n) operation.
*/
-__fast__
-void list_destroy(list_t* l)
+INLINE_MAYBE
+void list_destroy(list_t** l)
{
- while (l) {
- list_pop(&l);
+ while (*l) {
+ list_pop(l);
}
}
void list_reverse(list_t** l);
-#endif // __LIST_H__
+#endif // _LIST_H_