Commit b658d7e6 authored by Kimon Hoffmann's avatar Kimon Hoffmann
Browse files

Included structure definition in header file

[r6239]
parent 79c5b153
......@@ -5,52 +5,14 @@
* This list uses an obstack and a free-list to efficiently manage its
* elements.
* @author Kimon Hoffmann
* @date 17.07.2005
* @date 14.07.2005
* @note Until now the code is entirely untested so it probably contains
* plenty of errors.
*/
#include <stdlib.h>
#include "obst.h"
#include "plist.h"
/**
* Structure for one entry of the double linked pointer list.
*/
struct PListElement {
PListElement* next;
PListElement* prev;
void* data;
};
/**
* The list data type.
*/
struct PList {
/**
* The obstack used for all allocations.
*/
struct obstack obst;
/**
* First element in the list.
*/
PListElement* firstElement;
/**
* Last element in the list.
*/
PListElement* lastElement;
/**
* Current number of elements in the list.
*/
int elementCount;
/**
* First element in the free list.
* Please note that the free list is a single linked list and all back
* references are invalid.
*/
PListElement* firstFreeElement;
};
/**
* Helper macro that returns a new uninitialized list element by either
* fetching one from the free-list or allocating a new one on the lists
......@@ -116,7 +78,7 @@ void plist_insert_front(PList* list, void* value) {
}
void plist_insert_before(PList* list, PListElement* element, void* value) {
PListElement* prevElement;
PListElement* prevElement;
PListElement* newElement = allocate_element(list);
newElement->data = value;
......@@ -133,7 +95,7 @@ void plist_insert_before(PList* list, PListElement* element, void* value) {
}
void plist_insert_after(PList* list, PListElement* element, void* value) {
PListElement* nextElement;
PListElement* nextElement;
PListElement* newElement = allocate_element(list);
newElement->data = value;
......
......@@ -5,7 +5,7 @@
* This list uses an obstack and a free-list to efficiently manage its
* elements.
* @author Kimon Hoffmann
* @date 17.07.2005
* @date 14.07.2005
* @note Until now the code is entirely untested so it probably contains
* plenty of errors.
*/
......@@ -13,19 +13,50 @@
#define _PLIST_H_
#include <stddef.h>
#include "obst.h"
typedef struct PListElement PListElement;
typedef struct PList PList;
/**
* The Plist data type.
*/
typedef struct PList PList;
struct PList {
/**
* The obstack used for all allocations.
*/
struct obstack obst;
/**
* First element in the list.
*/
PListElement* firstElement;
/**
* Last element in the list.
*/
PListElement* lastElement;
/**
* Current number of elements in the list.
*/
int elementCount;
/**
* First element in the free list.
* Please note that the free list is a single linked list and all back
* references are invalid.
*/
PListElement* firstFreeElement;
};
/**
* An element in the pointer list.
*/
typedef struct PListElement PListElement;
struct PListElement {
PListElement* next;
PListElement* prev;
void* data;
};
/**
* Creates a new pointer list.
* Creates a new pointer list and initializes it.
* @return The newly created pointer list.
*/
PList* plist_new(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment