-static PListElement* allocate_element(PList* list) {
- PListElement* newElement;
- if (list->firstFreeElement != NULL) {
- newElement = list->firstFreeElement;
- list->firstFreeElement = newElement->next;
- newElement->next = NULL;
- } else {
- newElement = obstack_alloc(&list->obst, sizeof(*newElement));
- }
- return newElement;
+static plist_element_t *allocate_element(plist_t* list)
+{
+ plist_element_t *new_element;
+
+ if (list->first_free_element != NULL) {
+ new_element = list->first_free_element;
+ list->first_free_element = new_element->next;
+ new_element->next = NULL;
+ }
+ else {
+ new_element = OALLOC(list->obst, plist_element_t);
+ }
+
+ return new_element;
+}
+
+plist_t *plist_new(void)
+{
+ plist_t *list = (plist_t*) xmalloc(sizeof(*list) + sizeof(*list->obst));
+
+ list->obst = (struct obstack *)&list[1];
+ list->foreign_obstack = 0;
+ list->first_element = NULL;
+ list->last_element = NULL;
+ list->first_free_element = NULL;
+ list->element_count = 0;
+
+ obstack_init(list->obst);
+ return list;