summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-01-02 14:56:04 +0100
committerVolker Lendecke <vlendec@samba.org>2012-01-02 19:07:23 +0100
commitad3c0e03e2e1178a707ec6c529108f1df71a47a4 (patch)
tree71a6da56e25b697ed447d889c6a39252d9273f5e
parent0bee8719b2dffc98557b9b3d68bb589b5589f3a4 (diff)
downloadsamba-ad3c0e03e2e1178a707ec6c529108f1df71a47a4.tar.gz
samba-ad3c0e03e2e1178a707ec6c529108f1df71a47a4.tar.bz2
samba-ad3c0e03e2e1178a707ec6c529108f1df71a47a4.zip
talloc: Slightly simplify talloc_unlink
Nested if's are hard to understand to me. Signed-off-by: Stefan Metzmacher <metze@samba.org> Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Mon Jan 2 19:07:23 CET 2012 on sn-devel-104
-rw-r--r--lib/talloc/talloc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 8c71cc74ca..38e6f21854 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1043,7 +1043,7 @@ static inline int talloc_unreference(const void *context, const void *ptr)
*/
_PUBLIC_ int talloc_unlink(const void *context, void *ptr)
{
- struct talloc_chunk *tc_p, *new_p;
+ struct talloc_chunk *tc_p, *new_p, *tc_c;
void *new_parent;
if (ptr == NULL) {
@@ -1058,14 +1058,13 @@ _PUBLIC_ int talloc_unlink(const void *context, void *ptr)
return 0;
}
- if (context == NULL) {
- if (talloc_parent_chunk(ptr) != NULL) {
- return -1;
- }
+ if (context != NULL) {
+ tc_c = talloc_chunk_from_ptr(context);
} else {
- if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) {
- return -1;
- }
+ tc_c = NULL;
+ }
+ if (tc_c != talloc_parent_chunk(ptr)) {
+ return -1;
}
tc_p = talloc_chunk_from_ptr(ptr);