summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/talloc/Makefile.in19
-rw-r--r--source3/lib/talloc/configure.ac2
-rw-r--r--source3/lib/talloc/libtalloc.m410
-rw-r--r--source3/lib/talloc/talloc.3.xml21
-rw-r--r--source3/lib/talloc/talloc.c2
-rw-r--r--source3/lib/talloc/talloc.pc.in2
-rw-r--r--source3/lib/talloc/talloc_guide.txt21
-rw-r--r--source3/lib/talloc/testsuite.c42
8 files changed, 103 insertions, 16 deletions
diff --git a/source3/lib/talloc/Makefile.in b/source3/lib/talloc/Makefile.in
index 14e8115692..18b48c3459 100644
--- a/source3/lib/talloc/Makefile.in
+++ b/source3/lib/talloc/Makefile.in
@@ -12,12 +12,12 @@ builddir = @builddir@
XSLTPROC = @XSLTPROC@
INSTALLCMD = @INSTALL@
CC = @CC@
-CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I@srcdir@ -I@libreplacedir@
+CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I@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 @@ libtalloc.a: $(LIBOBJ)
@-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
diff --git a/source3/lib/talloc/configure.ac b/source3/lib/talloc/configure.ac
index 51e7256bf8..5f465fe93a 100644
--- a/source3/lib/talloc/configure.ac
+++ b/source3/lib/talloc/configure.ac
@@ -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)
diff --git a/source3/lib/talloc/libtalloc.m4 b/source3/lib/talloc/libtalloc.m4
index 4a0ee3c8fc..d2e8eba81a 100644
--- a/source3/lib/talloc/libtalloc.m4
+++ b/source3/lib/talloc/libtalloc.m4
@@ -12,8 +12,14 @@ done
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)
diff --git a/source3/lib/talloc/talloc.3.xml b/source3/lib/talloc/talloc.3.xml
index 2400fef2dc..83ca67a495 100644
--- a/source3/lib/talloc/talloc.3.xml
+++ b/source3/lib/talloc/talloc.3.xml
@@ -583,11 +583,27 @@ if (ptr) memcpy(ptr, p, strlen(p)+1);</programlisting>
</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 @@ if (ptr) memcpy(ptr, p, strlen(p)+1);</programlisting>
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>
diff --git a/source3/lib/talloc/talloc.c b/source3/lib/talloc/talloc.c
index b2b00d8c65..abc1e9438e 100644
--- a/source3/lib/talloc/talloc.c
+++ b/source3/lib/talloc/talloc.c
@@ -1137,6 +1137,8 @@ char *talloc_append_string(const void *t, char *orig, const char *append)
/* append the string with the trailing \0 */
memcpy(&ret[olen], append, alenz);
+ _talloc_set_name_const(ret, ret);
+
return ret;
}
diff --git a/source3/lib/talloc/talloc.pc.in b/source3/lib/talloc/talloc.pc.in
index f93036a33d..459cce70b1 100644
--- a/source3/lib/talloc/talloc.pc.in
+++ b/source3/lib/talloc/talloc.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
Name: talloc
Description: A hierarchical pool based memory system with destructors
-Version: 4.0
+Version: @PACKAGE_VERSION@
Libs: -L${libdir} -ltalloc
Cflags: -I${includedir}
URL: http://talloc.samba.org/
diff --git a/source3/lib/talloc/talloc_guide.txt b/source3/lib/talloc/talloc_guide.txt
index 8b252e4ab9..c4634ae19a 100644
--- a/source3/lib/talloc/talloc_guide.txt
+++ b/source3/lib/talloc/talloc_guide.txt
@@ -12,7 +12,7 @@ this carefully, as talloc has changed a lot. With 3.0.20 (or 3.0.14?) the
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,6 +533,15 @@ This functions sets the name of the new pointer to the passed
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);
@@ -540,6 +549,10 @@ 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, ...);
@@ -547,7 +560,7 @@ 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,6 +571,10 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...);
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);
diff --git a/source3/lib/talloc/testsuite.c b/source3/lib/talloc/testsuite.c
index d122a5de0d..587f270553 100644
--- a/source3/lib/talloc/testsuite.c
+++ b/source3/lib/talloc/testsuite.c
@@ -993,7 +993,7 @@ static bool test_talloc_ptrtype(void)
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,6 +1010,45 @@ static bool test_talloc_ptrtype(void)
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
@@ -1055,6 +1094,7 @@ bool torture_local_talloc(struct torture_context *tctx)
ret &= test_loop();
ret &= test_free_parent_deny_child();
ret &= test_talloc_ptrtype();
+ ret &= test_talloc_free_in_destructor();
if (ret) {
ret &= test_speed();