svn commit: samba r17895 - in branches/SAMBA_4_0/source/lib/talloc:
.
metze at samba.org
metze at samba.org
Mon Aug 28 18:21:22 GMT 2006
Author: metze
Date: 2006-08-28 18:21:21 +0000 (Mon, 28 Aug 2006)
New Revision: 17895
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17895
Log:
- talloc_increase_ref_count() can fail
- make talloc_reference() typesafe when gcc >= 3 is used
metze
Modified:
branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml
branches/SAMBA_4_0/source/lib/talloc/talloc.c
branches/SAMBA_4_0/source/lib/talloc/talloc.h
branches/SAMBA_4_0/source/lib/talloc/talloc_guide.txt
Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml 2006-08-28 18:00:45 UTC (rev 17894)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml 2006-08-28 18:21:21 UTC (rev 17895)
@@ -235,7 +235,7 @@
about to go away.
</para>
</refsect2>
- <refsect2><title>void talloc_increase_ref_count(const void *<emphasis role="italic">ptr</emphasis>);</title>
+ <refsect2><title>int talloc_increase_ref_count(const void *<emphasis role="italic">ptr</emphasis>);</title>
<para>
The talloc_increase_ref_count(<emphasis
role="italic">ptr</emphasis>) function is exactly equivalent to:
@@ -245,6 +245,9 @@
You can use either syntax, depending on which you think is
clearer in your code.
</para>
+ <para>
+ It returns 0 on success and -1 on failure.
+ </para>
</refsect2>
<refsect2 id="talloc_set_name"><title>void talloc_set_name(const void *ptr, const char *fmt, ...);</title>
<para>
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.c 2006-08-28 18:00:45 UTC (rev 17894)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.c 2006-08-28 18:21:21 UTC (rev 17895)
@@ -219,9 +219,12 @@
/*
increase the reference count on a piece of memory.
*/
-void talloc_increase_ref_count(const void *ptr)
+int talloc_increase_ref_count(const void *ptr)
{
- talloc_reference(null_context, ptr);
+ if (!talloc_reference(null_context, ptr)) {
+ return -1;
+ }
+ return 0;
}
/*
@@ -243,7 +246,7 @@
same underlying data, and you want to be able to free the two instances separately,
and in either order
*/
-void *talloc_reference(const void *context, const void *ptr)
+void *_talloc_reference(const void *context, const void *ptr)
{
struct talloc_chunk *tc;
struct talloc_reference_handle *handle;
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.h 2006-08-28 18:00:45 UTC (rev 17894)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.h 2006-08-28 18:21:21 UTC (rev 17895)
@@ -64,11 +64,13 @@
/* this extremely strange macro is to avoid some braindamaged warning
stupidity in gcc 4.1.x */
#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; })
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
#else
#define talloc_set_destructor(ptr, function) \
_talloc_set_destructor((ptr), (int (*)(void *))(function))
#define _TALLOC_TYPEOF(ptr) void *
#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr))
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
#endif
/* useful macros for creating type checked pointers */
@@ -107,8 +109,8 @@
/* The following definitions come from talloc.c */
void *_talloc(const void *context, size_t size);
void _talloc_set_destructor(const void *ptr, int (*destructor)(void *));
-void talloc_increase_ref_count(const void *ptr);
-void *talloc_reference(const void *context, const void *ptr);
+int talloc_increase_ref_count(const void *ptr);
+void *_talloc_reference(const void *context, const void *ptr);
int talloc_unlink(const void *context, void *ptr);
const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void talloc_set_name_const(const void *ptr, const char *name);
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc_guide.txt
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc_guide.txt 2006-08-28 18:00:45 UTC (rev 17894)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc_guide.txt 2006-08-28 18:21:21 UTC (rev 17895)
@@ -193,7 +193,7 @@
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_increase_ref_count(const void *ptr);
+int talloc_increase_ref_count(const void *ptr);
The talloc_increase_ref_count(ptr) function is exactly equivalent to:
@@ -202,6 +202,7 @@
You can use either syntax, depending on which you think is clearer in
your code.
+It returns 0 on success and -1 on failure.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void talloc_set_name(const void *ptr, const char *fmt, ...);
More information about the samba-cvs
mailing list