From: Ben Pfaff Date: Fri, 30 Jan 2009 00:47:03 +0000 (-0800) Subject: New function list_moved(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=854f009c80130ce5391612754b7ca3d3b5dd183c;p=openvswitch New function list_moved(). --- diff --git a/lib/list.c b/lib/list.c index 8eaf9fe9..89d15f11 100644 --- a/lib/list.c +++ b/lib/list.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -98,6 +98,14 @@ list_replace(struct list *element, const struct list *position) element->prev->next = element; } +/* Adjusts pointers around 'list' to compensate for 'list' having been moved + * around in memory (e.g. as a consequence of realloc()). */ +void +list_moved(struct list *list) +{ + list->prev->next = list->next->prev = list; +} + /* Removes 'elem' from its list and returns the element that followed it. Undefined behavior if 'elem' is not in a list. */ struct list * diff --git a/lib/list.h b/lib/list.h index 602c549b..7de8548c 100644 --- a/lib/list.h +++ b/lib/list.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -56,6 +56,7 @@ void list_splice(struct list *before, struct list *first, struct list *last); void list_push_front(struct list *, struct list *); void list_push_back(struct list *, struct list *); void list_replace(struct list *, const struct list *); +void list_moved(struct list *); /* List removal. */ struct list *list_remove(struct list *);