X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Flist.c;h=804a7e56adc10e452f008ffafed9ca2010931ce1;hb=c034de691814e208bad9fcb27fdd6eeb67cfa019;hp=b5fa3893aa4c1df1c76a0030f1d8907f8b1bf063;hpb=dc1539ae02fcb9c22b98d587b790ce8bc3a68774;p=sliver-openvswitch.git diff --git a/lib/list.c b/lib/list.c index b5fa3893a..804a7e56a 100644 --- a/lib/list.c +++ b/lib/list.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,11 @@ list_replace(struct list *element, const struct list *position) } /* Adjusts pointers around 'list' to compensate for 'list' having been moved - * around in memory (e.g. as a consequence of realloc()). */ + * around in memory (e.g. as a consequence of realloc()). + * + * This always works if 'list' is a member of a list, or if 'list' is the head + * of a non-empty list. It fails badly, however, if 'list' is the head of an + * empty list; just use list_init() in that case. */ void list_moved(struct list *list) { @@ -132,7 +136,7 @@ list_pop_back(struct list *list) struct list * list_front(const struct list *list_) { - struct list *list = (struct list *) list_; + struct list *list = CONST_CAST(struct list *, list_); assert(!list_is_empty(list)); return list->next; @@ -143,7 +147,7 @@ list_front(const struct list *list_) struct list * list_back(const struct list *list_) { - struct list *list = (struct list *) list_; + struct list *list = CONST_CAST(struct list *, list_); assert(!list_is_empty(list)); return list->prev;