summaryrefslogtreecommitdiff
path: root/source3/include/dlinklist.h
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-20 23:07:36 +0000
committerJeremy Allison <jra@samba.org>2001-03-20 23:07:36 +0000
commitbeec1ea8291c9c2b12745d37ffe307dd4e3bd6ec (patch)
tree5cefe9d779e5f11b398c8029796053ddfc61aceb /source3/include/dlinklist.h
parent344fb49fbf4df55492bfa9cc1aee2d8210c32ca6 (diff)
downloadsamba-beec1ea8291c9c2b12745d37ffe307dd4e3bd6ec.tar.gz
samba-beec1ea8291c9c2b12745d37ffe307dd4e3bd6ec.tar.bz2
samba-beec1ea8291c9c2b12745d37ffe307dd4e3bd6ec.zip
Fix for crash when doing name lookup with a quoted string. Part of
lookup_name was expecting to be able to write to the string. Changed lookup_name to use const. Jeremy. (This used to be commit 80c18d88491f1148ade623e81c33f84ba4f952f3)
Diffstat (limited to 'source3/include/dlinklist.h')
-rw-r--r--source3/include/dlinklist.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/include/dlinklist.h b/source3/include/dlinklist.h
index d510aad028..c35155d9bc 100644
--- a/source3/include/dlinklist.h
+++ b/source3/include/dlinklist.h
@@ -37,17 +37,17 @@
}\
}
-
-/* remove an element from a list */
+/* remove an element from a list - element doesn't have to be in list. */
#define DLIST_REMOVE(list, p) \
{ \
if ((p) == (list)) { \
(list) = (p)->next; \
if (list) (list)->prev = NULL; \
} else { \
- (p)->prev->next = (p)->next; \
+ if ((p)->prev) (p)->prev->next = (p)->next; \
if ((p)->next) (p)->next->prev = (p)->prev; \
} \
+ (p)->next = (p)->prev = NULL; \
}
/* promote an element to the top of the list */
@@ -57,10 +57,9 @@
DLIST_ADD(list, p) \
}
-/* demote an element to the top of the list, needs a tmp pointer */
-#define DLIST_DEMOTE(list, p, tmp) \
+/* hook into the end of the list - needs a tmp pointer */
+#define DLIST_ADD_END(list, p, tmp) \
{ \
- DLIST_REMOVE(list, p) \
if (!(list)) { \
(list) = (p); \
(p)->next = (p)->prev = NULL; \
@@ -71,3 +70,10 @@
(p)->prev = (tmp); \
} \
}
+
+/* demote an element to the top of the list, needs a tmp pointer */
+#define DLIST_DEMOTE(list, p, tmp) \
+{ \
+ DLIST_REMOVE(list, p) \
+ DLIST_ADD_END(list, p, tmp) \
+}