From 65f96eba32b93ced0717c2639007bba59da55fa4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:47:34 +0000 Subject: r4473: - moved talloc into its own lib/talloc/ area - added gcov flags to Makefile.talloc - expanded talloc testsuite to add a test for realloc with a child ptr - fixed a bug in talloc_realloc() with realloc of a ptr that has child ptrs (This used to be commit 98b5f73c1ba34d7576c5995069b485c1c5ede324) --- source4/lib/talloc/talloc.h | 96 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 source4/lib/talloc/talloc.h (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h new file mode 100644 index 0000000000..6ebba447aa --- /dev/null +++ b/source4/lib/talloc/talloc.h @@ -0,0 +1,96 @@ +#ifndef _TALLOC_H_ +#define _TALLOC_H_ +/* + Unix SMB/CIFS implementation. + Samba temporary memory allocation functions + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* this is only needed for compatibility with the old talloc */ +typedef void TALLOC_CTX; + +/* + this uses a little trick to allow __LINE__ to be stringified +*/ +#define _STRING_LINE_(s) #s +#define _STRING_LINE2_(s) _STRING_LINE_(s) +#define __LINESTR__ _STRING_LINE2_(__LINE__) +#define __location__ __FILE__ ":" __LINESTR__ + +/* useful macros for creating type checked pointers */ +#define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) +#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) +#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) +#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__) +#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__) +#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) + +#define talloc_destroy(ctx) talloc_free(ctx) + +#define malloc_p(type) (type *)malloc(sizeof(type)) +#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) +#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) + +#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) +#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) + +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a1, a2) +#endif + + +/* The following definitions come from lib/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_unlink(const void *context, void *ptr); +void talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void talloc_set_name_const(const void *ptr, const char *name); +void *talloc_named(const void *context, size_t size, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +void *talloc_named_const(const void *context, size_t size, const char *name); +const char *talloc_get_name(const void *ptr); +void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +int talloc_free(void *ptr); +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +void *talloc_steal(const void *new_ctx, const void *ptr); +off_t talloc_total_size(const void *ptr); +off_t talloc_total_blocks(const void *ptr); +void talloc_report_full(const void *ptr, FILE *f); +void talloc_report(const void *ptr, FILE *f); +void talloc_enable_leak_report(void); +void talloc_enable_leak_report_full(void); +void *_talloc_zero(const void *ctx, size_t size, const char *name); +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +char *talloc_strdup(const void *t, const char *p); +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, + const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_fn(const void *context, void *ptr, size_t size); + +#endif + -- cgit From f4b349127bdfe233476fe2efba961912f39a5cbd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 12:55:33 +0000 Subject: r4479: added the function talloc_autofree_context() which returns a talloc context that will automatically be freed on program exit. This is useful for reducing clutter in leak reports (This used to be commit cf73dda652e0a121901f22771104be6751c0fcb9) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 6ebba447aa..9e828f2f0d 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -91,6 +91,7 @@ void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char * void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); void *talloc_realloc_fn(const void *context, void *ptr, size_t size); +void *talloc_autofree_context(void); #endif -- cgit From cc55aef7c116d03ba2817625b0ba9edb378525e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 02:32:43 +0000 Subject: r4547: - added talloc_new(ctx) macro that is a neater form of the common talloc(ctx, 0) call. - cleaned up some talloc usage in various files I'd like to get to the point that we have no calls to talloc(), at which point we will rename talloc_p() to talloc(), to encourage everyone to use the typesafe functions. (This used to be commit e6c81d7c9f8a6938947d3c1c8a971a0d6d50b67a) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 9e828f2f0d..ee3e0be8eb 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -37,6 +37,7 @@ typedef void TALLOC_CTX; #define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) #define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) #define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) #define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__) -- cgit From ddc10d4d37984246a6547e34a32d629c689c40d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:06:58 +0000 Subject: r4549: got rid of a lot more uses of plain talloc(), instead using talloc_size() or talloc_array_p() where appropriate. also fixed a memory leak in pvfs_copy_file() (failed to free a memory context) (This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index ee3e0be8eb..99a6b7a770 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -34,6 +34,7 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -- cgit From e159e42d8472f36f51e400e351fc43f2a7dc44f5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:20:56 +0000 Subject: r4550: talloc() is now typesafe. It is exactly equivalent to the old talloc_p() macro. Use talloc_size() if you want the old behaviour. I have kept talloc_p() as an alias for now. Once we change all calls to be plain talloc() then we can remove it. (This used to be commit 2011bbeb841fd6bfccf3d44a49f79203f7f55baa) --- source4/lib/talloc/talloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 99a6b7a770..747b1c6ba6 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -33,11 +33,11 @@ typedef void TALLOC_CTX; #define __location__ __FILE__ ":" __LINESTR__ /* useful macros for creating type checked pointers */ -#define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_p(ctx, type) talloc(ctx, type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) -#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) #define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) #define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) -- cgit From 11ce2cfd70df264c5c91b4daaa9a01c5abc673b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jan 2005 04:39:16 +0000 Subject: r4591: - converted the other _p talloc functions to not need _p - added #if TALLOC_DEPRECATED around the _p functions - fixes the code that broke from the above while doing this I fixed quite a number of places that were incorrectly using the non type-safe talloc functions to use the type safe ones. Some were even doing multiplies for array allocation, which is potentially unsafe. (This used to be commit 6e7754abd0c225527fb38363996a6e241b87b37e) --- source4/lib/talloc/talloc.h | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 747b1c6ba6..8169782441 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -32,17 +32,26 @@ typedef void TALLOC_CTX; #define __LINESTR__ _STRING_LINE2_(__LINE__) #define __location__ __FILE__ ":" __LINESTR__ +#ifndef TALLOC_DEPRECATED +#define TALLOC_DEPRECATED 0 +#endif + /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_p(ctx, type) talloc(ctx, type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) -#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) + #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) -#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) -#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__) -#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__) + +#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) + +#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, __location__) +#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, __location__) +#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) + +#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, __location__) +#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) + #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) #define talloc_destroy(ctx) talloc_free(ctx) @@ -54,6 +63,14 @@ typedef void TALLOC_CTX; #define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) + +#if TALLOC_DEPRECATED +#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) +#define talloc_p(ctx, type) talloc(ctx, type) +#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) +#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) +#endif + #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a1, a2) #endif @@ -89,9 +106,9 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIB char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); -- cgit From 1bdbd21eb23d5591f005da13f1868343a4395dbe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 9 Jan 2005 02:37:24 +0000 Subject: r4609: add a usefull data_blob_dup_talloc() macro metze (This used to be commit 11e006df1689d4b4b202bca640106fd789495284) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 8169782441..5ac5888876 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -62,6 +62,7 @@ typedef void TALLOC_CTX; #define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) +#define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__) #if TALLOC_DEPRECATED -- cgit From 0c440d6506db46fdc7a26f5ef2790b6f4644f6e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jan 2005 15:20:55 +0000 Subject: r4687: use struct type and location for easier finding metze (This used to be commit a88aac7a397972c52ca2fb192b58f2a172630a6e) --- source4/lib/talloc/talloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 5ac5888876..cf03ce5952 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -37,7 +37,7 @@ typedef void TALLOC_CTX; #endif /* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type ": " __location__) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) -- cgit From 90d65c2e85c8042391b8219eeaedd780e6eb3c7c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jan 2005 15:38:25 +0000 Subject: r4689: - make talloc_report_depth() public - add talloc_parent() to return the parent context of a pointer these are very use full for debuging metze (This used to be commit 9b9501bc03ef8d4b53049f6b3531d06ed7ef7f89) --- source4/lib/talloc/talloc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index cf03ce5952..3483bb9e71 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -89,6 +89,8 @@ void *talloc_named(const void *context, size_t size, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); void *talloc_named_const(const void *context, size_t size, const char *name); const char *talloc_get_name(const void *ptr); +void talloc_report_depth(const void *ptr, FILE *f, int depth); +void *talloc_parent(const void *ptr); void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); int talloc_free(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -- cgit From 4b73689468ebe2e25a22d73fecb1a035b2303efd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Jan 2005 11:45:43 +0000 Subject: r4711: - deprecate talloc_destroy() - expanded the talloc_realloc() test a little (I was concerned about a possible bug, which turned out to be an illusion) - don't enable gcov by default in Makefile.talloc (This used to be commit 4ec47cc1083c4cdb780e548177631c5914bf677a) --- source4/lib/talloc/talloc.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 3483bb9e71..607ca4ca47 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -4,7 +4,7 @@ Unix SMB/CIFS implementation. Samba temporary memory allocation functions - Copyright (C) Andrew Tridgell 2004 + Copyright (C) Andrew Tridgell 2004-2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,8 +54,6 @@ typedef void TALLOC_CTX; #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) -#define talloc_destroy(ctx) talloc_free(ctx) - #define malloc_p(type) (type *)malloc(sizeof(type)) #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) #define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) @@ -70,6 +68,7 @@ typedef void TALLOC_CTX; #define talloc_p(ctx, type) talloc(ctx, type) #define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) #define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) +#define talloc_destroy(ctx) talloc_free(ctx) #endif #ifndef PRINTF_ATTRIBUTE -- cgit From 7b79694eadc288592729567c3caa7c70f6662760 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Jan 2005 23:21:52 +0000 Subject: r4790: added type checking helper macros in talloc. These take advantage of the type names that talloc already keeps around for pointers, and allows the user to type check void* private pointers. It can also be used to implement polymorphism in C, as I'm sure someone would have pointed out to me sooner or later :-) (This used to be commit c283e1a3efac3a92e29a35856e20eb61ef4c221e) --- source4/lib/talloc/talloc.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 607ca4ca47..0a98881054 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -37,7 +37,7 @@ typedef void TALLOC_CTX; #endif /* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type ": " __location__) +#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) @@ -45,11 +45,11 @@ typedef void TALLOC_CTX; #define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) #define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) -#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, __location__) -#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, __location__) +#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) #define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, __location__) +#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) #define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) @@ -62,6 +62,9 @@ typedef void TALLOC_CTX; #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) #define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__) +#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) +#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) + #if TALLOC_DEPRECATED #define talloc_zero_p(ctx, type) talloc_zero(ctx, type) @@ -76,7 +79,7 @@ typedef void TALLOC_CTX; #endif -/* The following definitions come from lib/talloc.c */ +/* 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); @@ -88,6 +91,7 @@ void *talloc_named(const void *context, size_t size, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); void *talloc_named_const(const void *context, size_t size, const char *name); const char *talloc_get_name(const void *ptr); +void *talloc_check_name(const void *ptr, const char *name); void talloc_report_depth(const void *ptr, FILE *f, int depth); void *talloc_parent(const void *ptr); void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -- cgit From 340d35be2d3f29a3176d86c0960398c2e36f921f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 22 Mar 2005 04:22:39 +0000 Subject: r5937: - performance improvement to talloc_asprintf_append() - allow standalone talloc to use gcc printf attributes (This used to be commit e25aa54e962796e6e7385afed57aa287ef6f869d) --- source4/lib/talloc/talloc.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 0a98881054..f639f3c8cf 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -75,8 +75,16 @@ typedef void TALLOC_CTX; #endif #ifndef PRINTF_ATTRIBUTE +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else #define PRINTF_ATTRIBUTE(a1, a2) #endif +#endif /* The following definitions come from talloc.c */ -- cgit From 0d36266cd4e0034ca5ed2755084a64db3e235ac4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 26 Mar 2005 10:47:44 +0000 Subject: r6075: added talloc_enable_null_tracking() (asked for by lifeless) (This used to be commit 40b8ee186af3e7f771c680dbbb03fdcf559bf103) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index f639f3c8cf..8b448f63c5 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -110,6 +110,7 @@ off_t talloc_total_size(const void *ptr); off_t talloc_total_blocks(const void *ptr); void talloc_report_full(const void *ptr, FILE *f); void talloc_report(const void *ptr, FILE *f); +void talloc_enable_null_tracking(void); void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); -- cgit From 157a32956a111b8cffcfa8d1c62a0ca67cdc0b22 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 7 May 2005 15:22:45 +0000 Subject: r6645: Add talloc_get_size() function. Sometimes it is usefull to know this data. Simo. (This used to be commit df401847827ef660d8b9d55af9b27bb85bad6b5f) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 8b448f63c5..ab549cf624 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -126,6 +126,7 @@ void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); +size_t talloc_get_size(const void *ctx); #endif -- cgit From 545203d9154a9ce0f5cc3800796581f62380074b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Jun 2005 05:03:54 +0000 Subject: r7778: added talloc_find_parent_bytype() and talloc_find_parent_byname() These provide a way to find a parent of a ptr that is of a given type. I will be using this to find the event context in smbd, relying on the fact that everything is a child of the top level event context. I did look at the alternatives, and found that passing the event context to just about every call in smbd was getting way too complex (we need to get it to anything that can do a ldb operation, as that can invoke ldap). So this method avoids a global, and seems to work nicely (This used to be commit bdb55c7a10a516b75652065e14f5acd09d24ab35) --- source4/lib/talloc/talloc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index ab549cf624..5160a3874a 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -65,6 +65,8 @@ typedef void TALLOC_CTX; #define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) +#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) + #if TALLOC_DEPRECATED #define talloc_zero_p(ctx, type) talloc_zero(ctx, type) @@ -127,6 +129,7 @@ void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); size_t talloc_get_size(const void *ctx); +void *talloc_find_parent_byname(const void *ctx, const char *name); #endif -- cgit From a124028b660ba5de566442302a8ee3b925595850 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Jun 2005 06:15:35 +0000 Subject: r7781: finding the parent of a talloc ptr is trickier than it looks due to the two-way tree nature of the data structure. I think I've finally got it right also added talloc_show_parents() for debugging (This used to be commit 5760ed20eed509b0b6e09e78c942dd0f70350fa9) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 5160a3874a..04d5cbb9af 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -130,6 +130,7 @@ void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); size_t talloc_get_size(const void *ctx); void *talloc_find_parent_byname(const void *ctx, const char *name); +void talloc_show_parents(const void *context, FILE *file); #endif -- cgit From 1702f52498168c0437416dec1014cedead634774 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Jun 2005 23:59:22 +0000 Subject: r7936: new ldb_dn_explode and ldb_dn_casefold functions and co (This used to be commit 7ccf21ab4eeb9821e457308a239f2103a106fb12) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 04d5cbb9af..d68510abef 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -119,6 +119,7 @@ void *_talloc_zero(const void *ctx, size_t size, const char *name); void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); char *talloc_strdup(const void *t, const char *p); char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_append_string(const void *t, char *orig, const char *append); char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, -- cgit From 4476dfd3bd34be68793a02ce0722b729528058fa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 1 Dec 2005 00:25:06 +0000 Subject: r11984: LGPL on header and testsuite as well (This used to be commit ed90975bf50644f00da681eb7cc41123abc60f81) --- source4/lib/talloc/talloc.h | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index d68510abef..2c5d04d605 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -6,19 +6,23 @@ Copyright (C) Andrew Tridgell 2004-2005 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* this is only needed for compatibility with the old talloc */ -- cgit From e4b7e8cdf1590d8ed9b1f190cad9ee6734ffe4de Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 31 Dec 2005 04:26:34 +0000 Subject: r12633: expose talloc_vasprintf_append() (This used to be commit 7a0e7074f6d3d38ce92f2b617549d5dbbaf968ef) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 2c5d04d605..68bf24e0b8 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -125,6 +125,7 @@ char *talloc_strdup(const void *t, const char *p); char *talloc_strndup(const void *t, const char *p, size_t n); char *talloc_append_string(const void *t, char *orig, const char *append); char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -- cgit From 5da75f5c3631247615efdf73fae2481df6908cb8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 May 2006 03:51:44 +0000 Subject: r15824: fixed a subtle talloc bug to do with memory context loops. When you have a structure that references one of its parents, and a parent of that parent is freed, then the whole structure should be freed, not just the reference. this was found by the change notify code, as a side effect of fixing the memory leak yesterday (This used to be commit 70531dcaeeb9314d410baa0d285df6a265311541) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 68bf24e0b8..99410241a6 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -137,6 +137,7 @@ void *talloc_autofree_context(void); size_t talloc_get_size(const void *ctx); void *talloc_find_parent_byname(const void *ctx, const char *name); void talloc_show_parents(const void *context, FILE *file); +int talloc_is_parent(const void *context, const char *ptr); #endif -- cgit From a665cccd2ef81e704e90bb228bbd14c0afb031af Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 May 2006 07:31:02 +0000 Subject: r15852: patch from Rusty to make talloc_set_destructor() and talloc_steal() type safe. This only works on recent gcc versions. With other compilers it reverts to a non-typesafe cast The patch also ensures that talloc_free() does not change error on systems where free() can change errno (This used to be commit babbff5f777642f559747f6d0697bc7c3a5e798d) --- source4/lib/talloc/talloc.h | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 99410241a6..be2b305753 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -40,6 +40,34 @@ typedef void TALLOC_CTX; #define TALLOC_DEPRECATED 0 #endif +#ifndef PRINTF_ATTRIBUTE +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + +/* try to make talloc_set_destructor() and talloc_steal() type safe, + if we have a recent gcc */ +#if (__GNUC__ >= 3) +#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) +#define talloc_set_destructor(ptr, function) \ + do { \ + int (*_talloc_destructor_fn)(typeof(ptr)) = (function); \ + _talloc_set_destructor((ptr), (void *)_talloc_destructor_fn); \ + } while(0) +#define _TALLOC_CHECK_TYPE(type,val) +#else +#define talloc_set_destructor(ptr, function) \ + _talloc_set_destructor((ptr), (int (*)(void *))(function)) +#define _TALLOC_TYPEOF(ptr) void * +#endif + /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) @@ -70,7 +98,7 @@ typedef void TALLOC_CTX; #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) #define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) - +#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) #if TALLOC_DEPRECATED #define talloc_zero_p(ctx, type) talloc_zero(ctx, type) @@ -80,22 +108,9 @@ typedef void TALLOC_CTX; #define talloc_destroy(ctx) talloc_free(ctx) #endif -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - - /* 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_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_unlink(const void *context, void *ptr); @@ -111,7 +126,7 @@ void *talloc_parent(const void *ptr); void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); int talloc_free(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *talloc_steal(const void *new_ctx, const void *ptr); +void *_talloc_steal(const void *new_ctx, const void *ptr); off_t talloc_total_size(const void *ptr); off_t talloc_total_blocks(const void *ptr); void talloc_report_full(const void *ptr, FILE *f); -- cgit From 816c055123ab2706ec09811e6375e6e8d8c8dd13 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 21 Jun 2006 19:28:24 +0000 Subject: r16446: talloc_set_name() allocates and can fail... pass the error to the callers metze (This used to be commit 7aa07a1e0b2abd1a6ecd490410685d20c0201094) --- source4/lib/talloc/talloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index be2b305753..d71e60cb45 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -114,7 +114,7 @@ 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_unlink(const void *context, void *ptr); -void talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +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); void *talloc_named(const void *context, size_t size, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -- cgit From ec2b3baf09ebff97bc958e73591e128f14c7a378 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 16:47:47 +0000 Subject: r16922: move some macros out of talloc.h as the don't belong to talloc metze (This used to be commit 4c68e315e2288eef97527911daf18622a994ac31) --- source4/lib/talloc/talloc.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index d71e60cb45..a4eef14bd0 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -86,14 +86,6 @@ typedef void TALLOC_CTX; #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) -#define malloc_p(type) (type *)malloc(sizeof(type)) -#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) -#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) - -#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) -#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) -#define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__) - #define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) -- cgit From 550f5fb26e67f46eead182476f7a9bcfd1ac5dc0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 21 Jul 2006 10:34:10 +0000 Subject: r17176: remove off_t from talloc. size_t is large enough to hold the max amount of memory of one process metze (This used to be commit f47b7bb656c8854c16c5a28ba24d18eeb22b6e22) --- source4/lib/talloc/talloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index a4eef14bd0..7591b6f318 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -119,8 +119,8 @@ void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); int talloc_free(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); void *_talloc_steal(const void *new_ctx, const void *ptr); -off_t talloc_total_size(const void *ptr); -off_t talloc_total_blocks(const void *ptr); +size_t talloc_total_size(const void *ptr); +size_t talloc_total_blocks(const void *ptr); void talloc_report_full(const void *ptr, FILE *f); void talloc_report(const void *ptr, FILE *f); void talloc_enable_null_tracking(void); -- cgit From 02ea24bcd1db8b11a9759ae8c7c99b7558bbe29c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 26 Jul 2006 17:32:47 +0000 Subject: r17263: export talloc_free_children() metze (This used to be commit 195754b169f68399008dda074181a2a16e4ecce5) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 7591b6f318..c6d20c820f 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -117,6 +117,7 @@ void talloc_report_depth(const void *ptr, FILE *f, int depth); void *talloc_parent(const void *ptr); void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); int talloc_free(void *ptr); +void talloc_free_children(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); void *_talloc_steal(const void *new_ctx, const void *ptr); size_t talloc_total_size(const void *ptr); -- cgit From f23be49188cec903446bea97261c3ea3774dea28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 Aug 2006 01:27:22 +0000 Subject: r17645: gcc 4.1.x has started producing "value computed is not used" warnings in very annoying ways for talloc_steal. This rather strange looking cpp approach avoids these warnings. It's really a problem in gcc, but better to do this than put up with the huge flood of warnings. (This used to be commit 8236a0ac5e80c30e52fccc0ef41a6c808ea43420) --- source4/lib/talloc/talloc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index c6d20c820f..b873bdb8aa 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -62,10 +62,14 @@ typedef void TALLOC_CTX; _talloc_set_destructor((ptr), (void *)_talloc_destructor_fn); \ } while(0) #define _TALLOC_CHECK_TYPE(type,val) +/* this extremely strange macro is to avoid some braindamaged warning + stupidity in gcc 4.1.x */ +#define talloc_steal(ctx, ptr) ({ __typeof__(ptr) __talloc_steal_ret = (__typeof__(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) #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)) #endif /* useful macros for creating type checked pointers */ @@ -90,7 +94,6 @@ typedef void TALLOC_CTX; #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) #define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) #if TALLOC_DEPRECATED #define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -- cgit From 82d4c5095dab0b5c1011fd9f5b865a7c07715a7a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Aug 2006 15:36:12 +0000 Subject: r17885: use _TALLOC_TYPEPF() consitently metze (This used to be commit 155cd6b88283b85c53c7ec65efcf431da7b649ac) --- source4/lib/talloc/talloc.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index b873bdb8aa..fec2e8d8d7 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -58,13 +58,12 @@ typedef void TALLOC_CTX; #define _TALLOC_TYPEOF(ptr) __typeof__(ptr) #define talloc_set_destructor(ptr, function) \ do { \ - int (*_talloc_destructor_fn)(typeof(ptr)) = (function); \ + int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ _talloc_set_destructor((ptr), (void *)_talloc_destructor_fn); \ } while(0) -#define _TALLOC_CHECK_TYPE(type,val) /* this extremely strange macro is to avoid some braindamaged warning stupidity in gcc 4.1.x */ -#define talloc_steal(ctx, ptr) ({ __typeof__(ptr) __talloc_steal_ret = (__typeof__(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) +#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) #else #define talloc_set_destructor(ptr, function) \ _talloc_set_destructor((ptr), (int (*)(void *))(function)) -- cgit From 5ed074715a7d63b803d5eaff3144a48304201df3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Aug 2006 16:55:51 +0000 Subject: r17886: add talloc_ptrtype() and talloc_array_ptrtype(), see the manpage what they do:-) metze (This used to be commit bfca83c91e47e9017474809cd7bc8b2e6e20416a) --- source4/lib/talloc/talloc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index fec2e8d8d7..40351693fa 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -74,6 +74,7 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) @@ -83,6 +84,7 @@ typedef void TALLOC_CTX; #define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) #define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) #define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) +#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) #define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) #define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) -- cgit From 45b8c41038c587b5993c6219bf6698323cf93494 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Aug 2006 17:38:49 +0000 Subject: r17891: remove c++ warnings from talloc metze (This used to be commit fb73ce8d4364a1da3c320034d90c0556529c61c4) --- source4/lib/talloc/talloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 40351693fa..b904029bda 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -59,7 +59,7 @@ typedef void TALLOC_CTX; #define talloc_set_destructor(ptr, function) \ do { \ int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (void *)_talloc_destructor_fn); \ + _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ } while(0) /* this extremely strange macro is to avoid some braindamaged warning stupidity in gcc 4.1.x */ @@ -149,7 +149,7 @@ void *talloc_autofree_context(void); size_t talloc_get_size(const void *ctx); void *talloc_find_parent_byname(const void *ctx, const char *name); void talloc_show_parents(const void *context, FILE *file); -int talloc_is_parent(const void *context, const char *ptr); +int talloc_is_parent(const void *context, const void *ptr); #endif -- cgit From 3400d91197aef446d6d113363f12edd7f14525a4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Aug 2006 17:50:26 +0000 Subject: r17893: add a function to disable the null_context metze (This used to be commit 7cab4285b1b61ad5cb425e42d89bcf7d645b0710) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index b904029bda..f080f0498d 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -129,6 +129,7 @@ size_t talloc_total_blocks(const void *ptr); void talloc_report_full(const void *ptr, FILE *f); void talloc_report(const void *ptr, FILE *f); void talloc_enable_null_tracking(void); +void talloc_disable_null_tracking(void); void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); -- cgit From 59057c8d56629a941ab412fa195dea7c8c486b21 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Aug 2006 18:21:21 +0000 Subject: r17895: - talloc_increase_ref_count() can fail - make talloc_reference() typesafe when gcc >= 3 is used metze (This used to be commit 933d1b47ad614d02cc02b602e704948b342febdb) --- source4/lib/talloc/talloc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index f080f0498d..9d6edd88ba 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -64,11 +64,13 @@ typedef void TALLOC_CTX; /* 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 @@ typedef void TALLOC_CTX; /* 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); -- cgit From 832ac85ba3e58d42f4342d79062bedf01e64c687 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 Aug 2006 09:51:49 +0000 Subject: r17907: - add a generic talloc_report_depth_cb() function which takes a callback to do the actual report. - make the talloc_report_depth_file() a wrapper of it - and talloc_report() and talloc_report_full() are wrapper of talloc_report_depth_file() metze (This used to be commit b199557b358e6216d89d233513079fcd56b307aa) --- source4/lib/talloc/talloc.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 9d6edd88ba..fdc0fd3494 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -5,6 +5,7 @@ Samba temporary memory allocation functions Copyright (C) Andrew Tridgell 2004-2005 + Copyright (C) Stefan Metzmacher 2006 ** NOTE! The following LGPL license applies to the talloc ** library. This does NOT imply that all of Samba is released @@ -110,6 +111,7 @@ typedef void TALLOC_CTX; void *_talloc(const void *context, size_t size); void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)); int talloc_increase_ref_count(const void *ptr); +size_t talloc_reference_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); @@ -119,7 +121,6 @@ void *talloc_named(const void *context, size_t size, void *talloc_named_const(const void *context, size_t size, const char *name); const char *talloc_get_name(const void *ptr); void *talloc_check_name(const void *ptr, const char *name); -void talloc_report_depth(const void *ptr, FILE *f, int depth); void *talloc_parent(const void *ptr); void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); int talloc_free(void *ptr); @@ -128,6 +129,13 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n void *_talloc_steal(const void *new_ctx, const void *ptr); size_t talloc_total_size(const void *ptr); size_t talloc_total_blocks(const void *ptr); +void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, + void (*callback)(const void *ptr, + int depth, int max_depth, + int is_ref, + void *private_data), + void *private_data); +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); void talloc_report_full(const void *ptr, FILE *f); void talloc_report(const void *ptr, FILE *f); void talloc_enable_null_tracking(void); @@ -142,8 +150,7 @@ char *talloc_append_string(const void *t, char *orig, const char *append); char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, - const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -- cgit From 1a5978445199a1d8697a5604761899aa065059fe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 00:05:07 +0000 Subject: r18435: added a function talloc_move() which is like talloc_steal(), but is meant for moving pointers between structures. The difference is that talloc_move() will zero the source pointer, thus ensuring you don't reference the pointer in the old context. talloc_move() is appropriate in some, but not all cases where we use talloc_steal() now. The interface came out of a discussion with Jeremy. (This used to be commit 200756017e1867faa207703eddc00a75ae4527df) --- source4/lib/talloc/talloc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index fdc0fd3494..b9ecd8f0b8 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -65,15 +65,16 @@ typedef void TALLOC_CTX; /* 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 +#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) +#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_move((ctx),&(ptr)) + /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) @@ -127,6 +128,7 @@ int talloc_free(void *ptr); void talloc_free_children(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); void *_talloc_steal(const void *new_ctx, const void *ptr); +void *_talloc_move(const void *new_ctx, const void **pptr); size_t talloc_total_size(const void *ptr); size_t talloc_total_blocks(const void *ptr); void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, -- cgit From 05cdd9ccafeeb384792b9ce7ca044bcec1bfc839 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 02:33:51 +0000 Subject: r18439: 2nd try at a talloc_move() api. This type with the ** ptr interface exposed. Unfortunately this generates a large number of type punning warnings. We'll have to find some magic to hide those. (This used to be commit 254cbf09dee5a1e20c47e47a298f1a8d172b41b9) --- source4/lib/talloc/talloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index b9ecd8f0b8..56f9dbb21a 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -73,7 +73,7 @@ typedef void TALLOC_CTX; #endif #define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_move((ctx),&(ptr)) +#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(const void **)(ptr)) /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -- cgit From c902a8927c517f1d8c8c5e083db48fd797ece8f4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 12:18:44 +0000 Subject: r18521: implement volkers suggestion for avoiding the type punning warnings (This used to be commit 9b9f058edb033c999c4430add4f05459ac43c9e2) --- source4/lib/talloc/talloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 56f9dbb21a..8b17eec03a 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -73,7 +73,7 @@ typedef void TALLOC_CTX; #endif #define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(const void **)(ptr)) +#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) @@ -128,7 +128,7 @@ int talloc_free(void *ptr); void talloc_free_children(void *ptr); void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); void *_talloc_steal(const void *new_ctx, const void *ptr); -void *_talloc_move(const void *new_ctx, const void **pptr); +void *_talloc_move(const void *new_ctx, const void *pptr); size_t talloc_total_size(const void *ptr); size_t talloc_total_blocks(const void *ptr); void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, -- cgit From bfbf6d546bcea8ea3051a4ff93ed69f1dbf45ffe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Dec 2006 22:45:36 +0000 Subject: r20193: - let talloc_parent_chunk() handle a NULL pointer - use talloc_parent_chunk() in talloc_parent_name() - add prototype of talloc_parent_name() metze (This used to be commit 85fc18f047cd2132d0c455f739ee76ce5005d7ed) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 8b17eec03a..75c130a275 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -123,6 +123,7 @@ void *talloc_named_const(const void *context, size_t size, const char *name); 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); -- cgit From 97416e6b011a3c733d07f83073bf12796c7ecc6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Feb 2007 12:12:12 +0000 Subject: r21297: Remove the GTK+ tools and library from the main repository. They are now maintained separately in bzr at http://people.samba.org/bzr/jelmer/samba-gtk This also adds some more headers to the list that is installed and a couple of extra #include lines so these headers can be used externally without problems. (This used to be commit 07652f65ce7a5b19130f1a27cbf0e1e5fae13454) --- source4/lib/talloc/talloc.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 75c130a275..628490faa6 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -26,6 +26,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include +#include + /* this is only needed for compatibility with the old talloc */ typedef void TALLOC_CTX; -- cgit From 9f7406f7956ce396fb8a79603aa4f9518ca46afe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:14:55 +0000 Subject: r22267: protect #define __location__ with an #ifndef metze (This used to be commit 138ffd6d486bb315ee6933f25e693d4207d870d6) --- source4/lib/talloc/talloc.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 628490faa6..195c6c25b6 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -36,10 +36,12 @@ typedef void TALLOC_CTX; /* this uses a little trick to allow __LINE__ to be stringified */ -#define _STRING_LINE_(s) #s -#define _STRING_LINE2_(s) _STRING_LINE_(s) -#define __LINESTR__ _STRING_LINE2_(__LINE__) -#define __location__ __FILE__ ":" __LINESTR__ +#ifndef __location__ +#define __TALLOC_STRING_LINE1__(s) #s +#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) +#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) +#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ +#endif #ifndef TALLOC_DEPRECATED #define TALLOC_DEPRECATED 0 -- cgit From b06fc3b53c2f17cfa3f86ef1472a5778400c0fc9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 21:09:16 +0000 Subject: r22539: Added _strict varients of the talloc calls to return NULL on size == 0 varients. Jeremy. (This used to be commit 1ef269067ca501e2a4ded4ca8654c6a6cc26f385) --- source4/lib/talloc/talloc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 195c6c25b6..fde2ddc0d8 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -89,10 +89,16 @@ typedef void TALLOC_CTX; #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) #define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +/* Varient of talloc_zero that returns NULL if size is zero. */ +#define talloc_zero_strict(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type) #define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +/* Varient of talloc_zero_array that returns NULL if count is zero. */ +#define talloc_zero_array_strict(ctx, type, count) (type *)_talloc_zero_array_strict(ctx, sizeof(type), count, #type) #define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +/* Varient of talloc_array that returns NULL if count is zero. */ +#define talloc_array_strict(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type) #define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) #define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) @@ -100,6 +106,8 @@ typedef void TALLOC_CTX; #define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) +/* Varient of talloc_memdup that returns NULL if count is zero. */ +#define talloc_memdup_strict(t, p, size) _talloc_memdup_strict(t, p, size, __location__) #define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) @@ -169,6 +177,6 @@ size_t talloc_get_size(const void *ctx); void *talloc_find_parent_byname(const void *ctx, const char *name); void talloc_show_parents(const void *context, FILE *file); int talloc_is_parent(const void *context, const void *ptr); +void *talloc_strict(const void *context, size_t size, const char *name); #endif - -- cgit From 3477721278b97212d47ddddde6f0ab060406aea3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 21:58:10 +0000 Subject: r22540: Added _strict varients of the macro calls - added prototypes. Jeremy. (This used to be commit ba1a66cc6febed8b9c809c59562414675df5f74e) --- source4/lib/talloc/talloc.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index fde2ddc0d8..357c9b5076 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -92,6 +92,7 @@ typedef void TALLOC_CTX; /* Varient of talloc_zero that returns NULL if size is zero. */ #define talloc_zero_strict(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type) #define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) +#define talloc_zero_size_strict(ctx, size) _talloc_zero_strict(ctx, size, __location__) #define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) /* Varient of talloc_zero_array that returns NULL if count is zero. */ @@ -100,6 +101,7 @@ typedef void TALLOC_CTX; /* Varient of talloc_array that returns NULL if count is zero. */ #define talloc_array_strict(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type) #define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) +#define talloc_array_size_strict(ctx, size, count) _talloc_array_strict(ctx, size, count, __location__) #define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) #define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) @@ -160,7 +162,9 @@ void talloc_disable_null_tracking(void); void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); +void *_talloc_zero_strict(const void *ctx, size_t size, const char *name); void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +void *_talloc_memdup_strict(const void *t, const void *p, size_t size, const char *name); char *talloc_strdup(const void *t, const char *p); char *talloc_strndup(const void *t, const char *p, size_t n); char *talloc_append_string(const void *t, char *orig, const char *append); @@ -169,7 +173,9 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRI char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_array_strict(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *_talloc_zero_array_strict(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); -- cgit From ca3a7a55789557331b7ffc810eae33a8f9859397 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 22:04:27 +0000 Subject: r22541: Added talloc_size_strict macro. Jeremy. (This used to be commit 219e1cae7792a5da886212f335ed11a35f28b3eb) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 357c9b5076..48bf4303c6 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -84,6 +84,7 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_size_strict(ctx, size) talloc_strict(ctx, size, __location__) #define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) -- cgit From 522f9ace1446e360ba84ed3cbe6cdb15946cc6c3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 28 Apr 2007 23:23:24 +0000 Subject: r22563: As tridge requested remove the _strict calls - for Samba3 I'm moving to a separate file. Jeremy. (This used to be commit 80706cf98d31593a899652acb2cdedaa8bf3dfab) --- source4/lib/talloc/talloc.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 48bf4303c6..d9e7d94338 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -84,33 +84,22 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_size_strict(ctx, size) talloc_strict(ctx, size, __location__) #define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) #define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -/* Varient of talloc_zero that returns NULL if size is zero. */ -#define talloc_zero_strict(ctx, type) (type *)_talloc_zero_strict(ctx, sizeof(type), #type) #define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) -#define talloc_zero_size_strict(ctx, size) _talloc_zero_strict(ctx, size, __location__) #define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -/* Varient of talloc_zero_array that returns NULL if count is zero. */ -#define talloc_zero_array_strict(ctx, type, count) (type *)_talloc_zero_array_strict(ctx, sizeof(type), count, #type) #define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -/* Varient of talloc_array that returns NULL if count is zero. */ -#define talloc_array_strict(ctx, type, count) (type *)_talloc_array_strict(ctx, sizeof(type), count, #type) #define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_array_size_strict(ctx, size, count) _talloc_array_strict(ctx, size, count, __location__) #define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) #define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) #define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) -/* Varient of talloc_memdup that returns NULL if count is zero. */ -#define talloc_memdup_strict(t, p, size) _talloc_memdup_strict(t, p, size, __location__) #define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) @@ -163,9 +152,7 @@ void talloc_disable_null_tracking(void); void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_zero_strict(const void *ctx, size_t size, const char *name); void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -void *_talloc_memdup_strict(const void *t, const void *p, size_t size, const char *name); char *talloc_strdup(const void *t, const char *p); char *talloc_strndup(const void *t, const char *p, size_t n); char *talloc_append_string(const void *t, char *orig, const char *append); @@ -174,9 +161,7 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRI char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_array_strict(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_zero_array_strict(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); void *talloc_realloc_fn(const void *context, void *ptr, size_t size); void *talloc_autofree_context(void); @@ -184,6 +169,5 @@ size_t talloc_get_size(const void *ctx); void *talloc_find_parent_byname(const void *ctx, const char *name); void talloc_show_parents(const void *context, FILE *file); int talloc_is_parent(const void *context, const void *ptr); -void *talloc_strict(const void *context, size_t size, const char *name); #endif -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/talloc/talloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index d9e7d94338..6778825822 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/talloc/talloc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 6778825822..15130d0d98 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include -- cgit From 151f422247e4f9a9645baf639adaf2dbd9557f13 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Sep 2007 17:40:58 +0000 Subject: r25164: Add talloc_asprintf_append_buffer() and the docs for it. Jeremy. (This used to be commit 5bb8613b86a6788efde840d5b50710f9afd22fed) --- source4/lib/talloc/talloc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 15130d0d98..95152a1416 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -157,8 +157,10 @@ char *talloc_strndup(const void *t, const char *p, size_t n); char *talloc_append_string(const void *t, char *orig, const char *append); char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -- cgit From 46d369b0f0ad9213e461457ec960cb43ec918ebe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Sep 2007 11:54:10 +0000 Subject: r25208: add talloc_str[n]dup_append[_buffer]() functions metze (This used to be commit 8532076720ddaf3409db1196550cd7c6884380fc) --- source4/lib/talloc/talloc.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 95152a1416..72af4dbfa8 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -152,15 +152,6 @@ void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -char *talloc_strdup(const void *t, const char *p); -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_append_string(const void *t, char *orig, const char *append); -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); @@ -171,4 +162,22 @@ void *talloc_find_parent_byname(const void *ctx, const char *name); void talloc_show_parents(const void *context, FILE *file); int talloc_is_parent(const void *context, const void *ptr); +char *talloc_strdup(const void *t, const char *p); +char *talloc_strdup_append(char *s, const char *a); +char *talloc_strdup_append_buffer(char *s, const char *a); + +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_strndup_append(char *s, const char *a, size_t n); +char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); + +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); + +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); + +char *talloc_append_string(const void *t, char *orig, const char *append); + #endif -- cgit From bc94aa19f30574dffcc56c98307dfab9772e6057 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Sep 2007 13:45:43 +0000 Subject: r25216: make talloc_append_string() a deprecated macro instead of having it as a real function. metze (This used to be commit 2b2e8414650f4793e7fd6e7fb368383ee268948f) --- source4/lib/talloc/talloc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index 72af4dbfa8..e103391681 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -111,6 +111,7 @@ typedef void TALLOC_CTX; #define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) #define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) #define talloc_destroy(ctx) talloc_free(ctx) +#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) #endif /* The following definitions come from talloc.c */ @@ -178,6 +179,4 @@ char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3) char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_append_string(const void *t, char *orig, const char *append); - #endif -- cgit From 7a9033fb2d2057dc8104d9b6f22c94e83e36f8ce Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 5 Jan 2008 18:26:54 +0100 Subject: Implement talloc_pool() A talloc pool is a chunk of memory that can be used as a context for further talloc calls. Allocations with the pool as the parent just chew from that memory by incrementing a pointer. If the talloc pool is full, then we fall back to the normal system-level malloc(3) to get memory. The use case for talloc pools is the transient memory that is used for handling a single SMB request. Incrementing a pointer will be way faster than any malloc implementation. There is a downside of this: If you use talloc_steal() to move something out of the pool, the whole pool memory is kept around until the last object inside the pool is freed. So if you talloc_free() the pool, it might happen that the memory is freed later. So don't hang anything off a talloc pool that should live long. Volker (This used to be commit 60ef9a84f0bd18d48e453c08aa420d17275e0881) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index e103391681..5431971655 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -116,6 +116,7 @@ typedef void TALLOC_CTX; /* The following definitions come from talloc.c */ void *_talloc(const void *context, size_t size); +void *talloc_pool(const void *context, size_t size); void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)); int talloc_increase_ref_count(const void *ptr); size_t talloc_reference_count(const void *ptr); -- cgit