svn commit: samba r20196 - in
branches/SAMBA_3_0_24/source/lib/talloc: .
metze at samba.org
metze at samba.org
Fri Dec 15 22:56:31 GMT 2006
Author: metze
Date: 2006-12-15 22:56:30 +0000 (Fri, 15 Dec 2006)
New Revision: 20196
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20196
Log:
merge talloc fixes from samba4:
- make most static functions inline
- handle NULL pointers in talloc_parent_chunk()
- use talloc_parent_chunk() in talloc_parent_name()
to fix a bug found by the IBM checker
metze
Modified:
branches/SAMBA_3_0_24/source/lib/talloc/talloc.c
branches/SAMBA_3_0_24/source/lib/talloc/talloc.h
Changeset:
Modified: branches/SAMBA_3_0_24/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/talloc/talloc.c 2006-12-15 22:51:31 UTC (rev 20195)
+++ branches/SAMBA_3_0_24/source/lib/talloc/talloc.c 2006-12-15 22:56:30 UTC (rev 20196)
@@ -162,10 +162,17 @@
/*
return the parent chunk of a pointer
*/
-static struct talloc_chunk *talloc_parent_chunk(const void *ptr)
+static inline 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
*/
@@ -265,6 +261,8 @@
/*
helper for talloc_reference()
+
+ this is referenced by a function pointer and should not be inline
*/
static int talloc_reference_destructor(struct talloc_reference_handle *handle)
{
@@ -481,7 +479,7 @@
talloc_reference() has done. The context and pointer arguments
must match those given to a talloc_reference()
*/
-static int talloc_unreference(const void *context, const void *ptr)
+static inline int talloc_unreference(const void *context, const void *ptr)
{
struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
struct talloc_reference_handle *h;
@@ -561,9 +559,9 @@
/*
add a name to an existing pointer - va_list version
*/
-static const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-static const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
+static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
{
struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
tc->name = talloc_vasprintf(ptr, fmt, ap);
Modified: branches/SAMBA_3_0_24/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_3_0_24/source/lib/talloc/talloc.h 2006-12-15 22:51:31 UTC (rev 20195)
+++ branches/SAMBA_3_0_24/source/lib/talloc/talloc.h 2006-12-15 22:56:30 UTC (rev 20196)
@@ -123,7 +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 *context);
+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