X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fplist.c;h=aea85f5f58e6b5153c4e0f34c00f4d0e96225a33;hb=31ef53136fdb86d4a98919c2148c95cadea4ea81;hp=622e23b5ba14257739e57841d7251eb9de524808;hpb=d7757e15942ccff3df4b9bfb3efc3e2656220fcd;p=libfirm diff --git a/ir/adt/plist.c b/ir/adt/plist.c index 622e23b5b..aea85f5f5 100644 --- a/ir/adt/plist.c +++ b/ir/adt/plist.c @@ -1,14 +1,32 @@ +/* + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /** - * Simple, non circular, double linked pointer list. - * Created because the properties of the standard circular list were not - * very well suited for the interference graph implementation. - * This list uses an obstack and a free-list to efficiently manage its - * elements. - * @author Kimon Hoffmann - * @date 14.07.2005 - * @cvs-id $Id$ - * @note Until now the code is entirely untested so it probably contains - * plenty of errors. + * @file + * @brief Simple, non circular, double linked pointer list. + * @note Created because the properties of the standard circular list were not + * very well suited for the interference graph implementation. + * This list uses an obstack and a free-list to efficiently manage its + * elements. + * @author Kimon Hoffmann + * @date 14.07.2005 + * @version $Id$ */ #include @@ -36,18 +54,17 @@ static plist_element_t *allocate_element(plist_t* list) { return new_element; } -plist_t* plist_new(void) { - plist_t* list = xmalloc(sizeof(*list)); - - list->obst = xmalloc(sizeof(*list->obst)); - obstack_init(list->obst); +plist_t *plist_new(void) { + plist_t *list = 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; } @@ -72,17 +89,16 @@ void plist_free(plist_t *list) { if (! list->foreign_obstack) { obstack_free(list->obst, NULL); - xfree(list->obst); xfree(list); } } -void plist_insert_back(plist_t* list, void* value) { +void plist_insert_back(plist_t *list, void *value) { if (list->last_element != NULL) { plist_insert_after(list, list->last_element, value); } else { - plist_element_t* newElement = allocate_element(list); + plist_element_t *newElement = allocate_element(list); newElement->data = value; newElement->prev = NULL; @@ -92,12 +108,12 @@ void plist_insert_back(plist_t* list, void* value) { } } -void plist_insert_front(plist_t* list, void* value) { +void plist_insert_front(plist_t *list, void *value) { if (list->first_element != NULL) { plist_insert_before(list, list->first_element, value); } else { - plist_element_t* newElement = allocate_element(list); + plist_element_t *newElement = allocate_element(list); newElement->data = value; newElement->prev = NULL; @@ -107,9 +123,9 @@ void plist_insert_front(plist_t* list, void* value) { } } -void plist_insert_before(plist_t* list, plist_element_t* element, void* value) { - plist_element_t* prevElement; - plist_element_t* newElement = allocate_element(list); +void plist_insert_before(plist_t *list, plist_element_t *element, void *value) { + plist_element_t *prevElement; + plist_element_t *newElement = allocate_element(list); newElement->data = value; newElement->next = element; @@ -128,8 +144,8 @@ void plist_insert_before(plist_t* list, plist_element_t* element, void* value) { } void plist_insert_after(plist_t* list, plist_element_t* element, void* value) { - plist_element_t* nextElement; - plist_element_t* newElement = allocate_element(list); + plist_element_t *nextElement; + plist_element_t *newElement = allocate_element(list); newElement->data = value; newElement->prev = element;