svn commit: samba r20193 - in branches/SAMBA_4_0/source/lib/talloc: .

metze at samba.org metze at samba.org
Fri Dec 15 22:45:37 GMT 2006


Author: metze
Date: 2006-12-15 22:45:36 +0000 (Fri, 15 Dec 2006)
New Revision: 20193

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20193

Log:
- let talloc_parent_chunk() handle a NULL pointer
- use talloc_parent_chunk() in talloc_parent_name()
- add prototype of talloc_parent_name()

metze
Modified:
   branches/SAMBA_4_0/source/lib/talloc/talloc.c
   branches/SAMBA_4_0/source/lib/talloc/talloc.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.c	2006-12-15 22:37:06 UTC (rev 20192)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.c	2006-12-15 22:45:36 UTC (rev 20193)
@@ -164,8 +164,15 @@
 */
 static struct talloc_chunk *talloc_parent_chunk(const void *ptr)
 {
-	struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+	struct talloc_chunk *tc;
+
+	if (unlikely(ptr == NULL)) {
+		return NULL;
+	}
+
+	tc = talloc_chunk_from_ptr(ptr);
 	while (tc->prev) tc=tc->prev;
+
 	return tc->parent;
 }
 
@@ -178,23 +185,12 @@
 /*
   find parents name
 */
-const char *talloc_parent_name(const void *context)
+const char *talloc_parent_name(const void *ptr)
 {
-	struct talloc_chunk *tc;
-
-	if (unlikely(context == NULL)) {
-		return NULL;
-	}
-
-	tc = talloc_chunk_from_ptr(context);
-	while (tc && tc->prev) tc = tc->prev;
-	if (tc) {
-		tc = tc->parent;
-	}
-	return tc->name;
+	struct talloc_chunk *tc = talloc_parent_chunk(ptr);
+	return tc? tc->name : NULL;
 }
 
-
 /* 
    Allocate a bit of memory as a child of an existing pointer
 */

Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.h	2006-12-15 22:37:06 UTC (rev 20192)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.h	2006-12-15 22:45:36 UTC (rev 20193)
@@ -123,6 +123,7 @@
 const char *talloc_get_name(const void *ptr);
 void *talloc_check_name(const void *ptr, const char *name);
 void *talloc_parent(const void *ptr);
+const char *talloc_parent_name(const void *ptr);
 void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
 int talloc_free(void *ptr);
 void talloc_free_children(void *ptr);



More information about the samba-cvs mailing list