From 854f009c80130ce5391612754b7ca3d3b5dd183c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 29 Jan 2009 16:47:03 -0800 Subject: [PATCH] New function list_moved(). --- lib/list.c | 10 +++++++++- lib/list.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) 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 *); -- 2.30.2