svn commit: samba r22760 - in branches/SAMBA_3_0_26/source/lib/talloc: .

metze at samba.org metze at samba.org
Tue May 8 11:14:23 GMT 2007


Author: metze
Date: 2007-05-08 11:14:21 +0000 (Tue, 08 May 2007)
New Revision: 22760

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

Log:
sync lib/talloc with SAMBA_3_0 and SAMBA_4_0

metze
Modified:
   branches/SAMBA_3_0_26/source/lib/talloc/Makefile.in
   branches/SAMBA_3_0_26/source/lib/talloc/config.mk
   branches/SAMBA_3_0_26/source/lib/talloc/configure.ac
   branches/SAMBA_3_0_26/source/lib/talloc/libtalloc.m4
   branches/SAMBA_3_0_26/source/lib/talloc/talloc.3.xml
   branches/SAMBA_3_0_26/source/lib/talloc/talloc.c
   branches/SAMBA_3_0_26/source/lib/talloc/talloc.h
   branches/SAMBA_3_0_26/source/lib/talloc/talloc.pc.in
   branches/SAMBA_3_0_26/source/lib/talloc/talloc_guide.txt
   branches/SAMBA_3_0_26/source/lib/talloc/testsuite.c


Changeset:
Modified: branches/SAMBA_3_0_26/source/lib/talloc/Makefile.in
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/Makefile.in	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/Makefile.in	2007-05-08 11:14:21 UTC (rev 22760)
@@ -12,12 +12,12 @@
 XSLTPROC = @XSLTPROC@
 INSTALLCMD = @INSTALL@
 CC = @CC@
-CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I at srcdir@ -I at libreplacedir@
+CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I at srcdir@
 EXTRA_TARGETS = @DOC_TARGET@
 
 .SUFFIXES: .c .o .3 .3.xml .xml .html
 
-LIBOBJ = @TALLOCOBJ@ @LIBREPLACEOBJ@
+LIBOBJ = @TALLOC_OBJ@ @LIBREPLACEOBJ@
 
 all: showflags libtalloc.a testsuite $(EXTRA_TARGETS)
 
@@ -34,13 +34,14 @@
 	@-ranlib $@
 
 install: all 
-	${INSTALLCMD} -d ${libdir}
-	${INSTALLCMD} -m 755 libtalloc.a $(libdir)
-	${INSTALLCMD} -d ${includedir}
-	${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(includedir)
-	${INSTALLCMD} -m 644 talloc.pc $(libdir)/pkgconfig
-	if [ -f talloc.3 ];then ${INSTALLCMD} -d ${mandir}/man3; fi
-	if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(mandir)/man3; fi
+	${INSTALLCMD} -d $(DESTDIR)$(libdir)
+	${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig
+	${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir)
+	${INSTALLCMD} -d $(DESTDIR)${includedir}
+	${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir)
+	${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig
+	if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi
+	if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi
 
 doc: talloc.3 talloc.3.html
 

Modified: branches/SAMBA_3_0_26/source/lib/talloc/config.mk
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/config.mk	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/config.mk	2007-05-08 11:14:21 UTC (rev 22760)
@@ -11,8 +11,3 @@
 #
 # End LIBRARY LIBTALLOC
 ################################################
-
-[BINARY::TALLOC]
-OBJ_FILES = testsuite.o
-PRIVATE_DEPENDENCIES = LIBTALLOC
-INSTALLDIR = TORTUREDIR/LOCAL

Modified: branches/SAMBA_3_0_26/source/lib/talloc/configure.ac
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/configure.ac	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/configure.ac	2007-05-08 11:14:21 UTC (rev 22760)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.50)
-AC_INIT(talloc.h)
+AC_INIT(talloc, 1.0)
 AC_CONFIG_SRCDIR([talloc.c])
 AC_SUBST(datarootdir)
 AC_CONFIG_HEADER(config.h)

Modified: branches/SAMBA_3_0_26/source/lib/talloc/libtalloc.m4
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/libtalloc.m4	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/libtalloc.m4	2007-05-08 11:14:21 UTC (rev 22760)
@@ -12,9 +12,15 @@
 if test x"$tallocdir" = "x"; then
    AC_MSG_ERROR([cannot find talloc source in $tallocpaths])
 fi
-TALLOCOBJ="talloc.o"
-AC_SUBST(TALLOCOBJ)
+TALLOC_OBJ="talloc.o"
+AC_SUBST(TALLOC_OBJ)
 
+TALLOC_CFLAGS="-I$tallocdir"
+AC_SUBST(TALLOC_CFLAGS)
+
+TALLOC_LIBS=""
+AC_SUBST(TALLOC_LIBS)
+
 AC_CHECK_SIZEOF(size_t,cross)
 AC_CHECK_SIZEOF(void *,cross)
 

Modified: branches/SAMBA_3_0_26/source/lib/talloc/talloc.3.xml
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/talloc.3.xml	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/talloc.3.xml	2007-05-08 11:14:21 UTC (rev 22760)
@@ -583,11 +583,27 @@
         </para>
         <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
     </refsect2>
+    <refsect2><title>char *talloc_append_string(const void *<emphasis role="italic">t</emphasis>, char *<emphasis role="italic">orig</emphasis>, const char *<emphasis role="italic">append</emphasis>);</title>
+        <para>
+	  The talloc_append_string() function appends the given formatted
+	  string to the given string.
+        </para>
+        <para>
+	  This function sets the name of the new pointer to the new
+	  string. This is equivalent to:
+        </para>
+        <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
+    </refsect2>
     <refsect2><title>char *talloc_vasprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, va_list <emphasis role="italic">ap</emphasis>);</title>
         <para>
 	  The talloc_vasprintf() function is the talloc equivalent of the C
 	  library function vasprintf(3).
         </para>
+        <para>
+	  This function sets the name of the new pointer to the new
+	  string. This is equivalent to:
+        </para>
+        <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
     </refsect2>
     <refsect2><title>char *talloc_asprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, ...);</title>
         <para>
@@ -605,6 +621,11 @@
 	  The talloc_asprintf_append() function appends the given formatted
 	  string to the given string.
         </para>
+        <para>
+	  This function sets the name of the new pointer to the new
+	  string. This is equivalent to:
+        </para>
+        <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
     </refsect2>
     <refsect2><title>(type *)talloc_array(const void *ctx, type, uint_t count);</title>
         <para>

Modified: branches/SAMBA_3_0_26/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/talloc.c	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/talloc.c	2007-05-08 11:14:21 UTC (rev 22760)
@@ -1137,6 +1137,8 @@
 	/* append the string with the trailing \0 */
 	memcpy(&ret[olen], append, alenz);
 
+	_talloc_set_name_const(ret, ret);
+
 	return ret;
 }
 

Modified: branches/SAMBA_3_0_26/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/talloc.h	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/talloc.h	2007-05-08 11:14:21 UTC (rev 22760)
@@ -26,6 +26,10 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
 /* this is only needed for compatibility with the old talloc */
 typedef void TALLOC_CTX;
 

Modified: branches/SAMBA_3_0_26/source/lib/talloc/talloc.pc.in
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/talloc.pc.in	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/talloc.pc.in	2007-05-08 11:14:21 UTC (rev 22760)
@@ -5,6 +5,7 @@
 
 Name: talloc 
 Description: A hierarchical pool based memory system with destructors
-Version: 4.0
-Libs: @LIBS@ -L${libdir} -ltalloc
-Cflags: -I${includedir} @CFLAGS@
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -ltalloc
+Cflags: -I${includedir} 
+URL: http://talloc.samba.org/

Modified: branches/SAMBA_3_0_26/source/lib/talloc/talloc_guide.txt
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/talloc_guide.txt	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/talloc_guide.txt	2007-05-08 11:14:21 UTC (rev 22760)
@@ -12,7 +12,7 @@
 Samba4 talloc has been ported back to Samba3, so this guide applies to both.
 
 The new talloc is a hierarchical, reference counted memory pool system
-with destructors. Quite a mounthful really, but not too bad once you
+with destructors. Quite a mouthful really, but not too bad once you
 get used to it.
 
 Perhaps the biggest change from Samba3 is that there is no distinction
@@ -533,21 +533,34 @@
 string. This is equivalent to:
    talloc_set_name_const(ptr, ptr)
 
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+char *talloc_append_string(const void *t, char *orig, const char *append);
 
+The talloc_append_string() function appends the given formatted
+string to the given string.
+
+This function sets the name of the new pointer to the new
+string. This is equivalent to:
+   talloc_set_name_const(ptr, ptr)
+
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 char *talloc_vasprintf(const void *t, const char *fmt, va_list ap);
 
 The talloc_vasprintf() function is the talloc equivalent of the C
 library function vasprintf()
 
+This functions sets the name of the new pointer to the new
+string. This is equivalent to:
+   talloc_set_name_const(ptr, ptr)
 
+
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 char *talloc_asprintf(const void *t, const char *fmt, ...);
 
 The talloc_asprintf() function is the talloc equivalent of the C
 library function asprintf()
 
-This functions sets the name of the new pointer to the passed
+This functions sets the name of the new pointer to the new
 string. This is equivalent to:
    talloc_set_name_const(ptr, ptr)
 
@@ -558,7 +571,11 @@
 The talloc_asprintf_append() function appends the given formatted 
 string to the given string. 
 
+This functions sets the name of the new pointer to the new
+string. This is equivalent to:
+   talloc_set_name_const(ptr, ptr)
 
+
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 (type *)talloc_array(const void *ctx, type, uint_t count);
 

Modified: branches/SAMBA_3_0_26/source/lib/talloc/testsuite.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/talloc/testsuite.c	2007-05-08 11:12:11 UTC (rev 22759)
+++ branches/SAMBA_3_0_26/source/lib/talloc/testsuite.c	2007-05-08 11:14:21 UTC (rev 22760)
@@ -993,7 +993,7 @@
 	s4 = talloc_array_ptrtype(top, s4, 10);location4 = __location__;
 
 	if (talloc_get_size(s4) != (sizeof(struct struct1 **) * 10)) {
-		printf("failure: TALLOC PTRTYPE [\n"
+		printf("failure: ptrtype [\n"
 		      "talloc_array_ptrtype() allocated the wrong size "
 		       "%lu (should be %lu)\n]\n",
 			   (unsigned long)talloc_get_size(s4),
@@ -1010,8 +1010,49 @@
 	return true;
 }
 
+static int _test_talloc_free_in_destructor(void **ptr)
+{
+	talloc_free(*ptr);
+	return 0;
+}
+
+static bool test_talloc_free_in_destructor(void)
+{
+	void *level0;
+	void *level1;
+	void *level2;
+	void *level3;
+	void *level4;
+	void **level5;
+
+	printf("test: free_in_destructor [\nTALLOC FREE IN DESTRUCTOR\n]\n");
+
+	level0 = talloc_new(NULL);
+	level1 = talloc_new(level0);
+	level2 = talloc_new(level1);
+	level3 = talloc_new(level2);
+	level4 = talloc_new(level3);
+	level5 = talloc(level4, void *);
+
+	*level5 = level3;
+	(void)talloc_reference(level0, level3);
+	(void)talloc_reference(level3, level3);
+	(void)talloc_reference(level5, level3);
+
+	talloc_set_destructor(level5, _test_talloc_free_in_destructor);
+
+	talloc_free(level1);
+
+	talloc_free(level0);
+
+	printf("success: free_in_destructor\n");
+	return true;
+}
+
 static bool test_autofree(void)
 {
+#if _SAMBA_BUILD_ < 4
+	/* autofree test would kill smbtorture */
 	void *p;
 	printf("test: autofree [\nTALLOC AUTOFREE CONTEXT\n]\n");
 
@@ -1022,13 +1063,17 @@
 	talloc_free(p);
 
 	printf("success: autofree\n");
+#endif
 	return true;
 }
 
-int main(void)
+struct torture_context;
+bool torture_local_talloc(struct torture_context *tctx)
 {
 	bool ret = true;
 
+	setlinebuf(stdout);
+
 	talloc_disable_null_tracking();
 	talloc_enable_null_tracking();
 
@@ -1049,13 +1094,22 @@
 	ret &= test_loop();
 	ret &= test_free_parent_deny_child(); 
 	ret &= test_talloc_ptrtype();
+	ret &= test_talloc_free_in_destructor();
 
 	if (ret) {
 		ret &= test_speed();
 	}
 	ret &= test_autofree();
 
+	return ret;
+}
+
+#if _SAMBA_BUILD_ < 4
+int main(void)
+{
+	bool ret = torture_local_talloc(NULL);
 	if (!ret)
 		return -1;
 	return 0;
 }
+#endif



More information about the samba-cvs mailing list