diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-08-29 16:54:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:59 -0500 |
commit | 9c8a9d0ac4cb062e8de25a5dbaed823e597a128f (patch) | |
tree | 52648e7d318094f269d0c11e8e2c97a974ad82ea /source3/lib | |
parent | 3247b4f15a11c531d79ca8137a4f36d63069591b (diff) | |
download | samba-9c8a9d0ac4cb062e8de25a5dbaed823e597a128f.tar.gz samba-9c8a9d0ac4cb062e8de25a5dbaed823e597a128f.tar.bz2 samba-9c8a9d0ac4cb062e8de25a5dbaed823e597a128f.zip |
r17922: sync samba3's talloc with samba4's and move the samba3 specific stuff to tallocmsg.c
metze
(This used to be commit 7704e3e51dec1768772663024a0579cb4a271cc1)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/talloc.c | 356 | ||||
-rw-r--r-- | source3/lib/tallocmsg.c | 49 | ||||
-rw-r--r-- | source3/lib/util.c | 2 |
3 files changed, 206 insertions, 201 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index 0e223e8bbe..2fb8fb2530 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -1,4 +1,4 @@ -/* +/* Samba Unix SMB/CIFS implementation. Samba trivial allocation library - new interface @@ -6,11 +6,12 @@ NOTE: Please read talloc_guide.txt for full documentation Copyright (C) Andrew Tridgell 2004 - + 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 ** under the LGPL - + 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 @@ -31,8 +32,9 @@ */ #ifdef _SAMBA_BUILD_ +#include "version.h" +#if (SAMBA_VERSION_MAJOR<4) #include "includes.h" -#if ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) /* This is to circumvent SAMBA3's paranoid malloc checker. Here in this file * we trust ourselves... */ #ifdef malloc @@ -41,18 +43,32 @@ #ifdef realloc #undef realloc #endif -#endif -#else +#define _TALLOC_SAMBA3 +#endif /* (SAMBA_VERSION_MAJOR<4) */ +#endif /* _SAMBA_BUILD_ */ + +#ifndef _TALLOC_SAMBA3 +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> +#include <errno.h> +#ifdef HAVE_STDINT_H #include <stdint.h> -#include "talloc.h" -/* assume a modern system */ -#define HAVE_VA_COPY #endif +#if defined(HAVE_STDARG_H) +#include <stdarg.h> +#elif defined (HAVE_VARARGS_H) +#include <varargs.h> +#else +#error "no var arg header" +#endif + +#include "talloc.h" +#endif /* not _TALLOC_SAMBA3 */ + /* use this to force every realloc to change the pointer, to stress test code that might not cope */ #define ALWAYS_REALLOC 0 @@ -82,11 +98,9 @@ talloc_enable_leak_report_full() is called, otherwise it remains NULL */ -static const void *null_context; +static void *null_context; static void *cleanup_context; -static void *talloc_steal(const void *new_ctx, const void *ptr); - struct talloc_reference_handle { struct talloc_reference_handle *next, *prev; void *ptr; @@ -215,7 +229,7 @@ void *_talloc(const void *context, size_t size) if the destructor fails then the free is failed, and the memory can be continued to be used */ -void talloc_set_destructor(const void *ptr, int (*destructor)(void *)) +void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)) { struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); tc->destructor = destructor; @@ -224,25 +238,21 @@ void talloc_set_destructor(const void *ptr, int (*destructor)(void *)) /* increase the reference count on a piece of memory. */ -void talloc_increase_ref_count(const void *ptr) +int talloc_increase_ref_count(const void *ptr) { - talloc_reference(null_context, ptr); + if (!talloc_reference(null_context, ptr)) { + return -1; + } + return 0; } /* helper for talloc_reference() */ -static int talloc_reference_destructor(void *ptr) +static int talloc_reference_destructor(struct talloc_reference_handle *handle) { - struct talloc_reference_handle *handle = - (struct talloc_reference_handle *)ptr; - struct talloc_chunk *tc1 = talloc_chunk_from_ptr(ptr); - struct talloc_chunk *tc2 = talloc_chunk_from_ptr(handle->ptr); - if (tc1->destructor != (talloc_destructor_t)-1) { - tc1->destructor = NULL; - } - _TLIST_REMOVE(tc2->refs, handle); - talloc_free(handle); + struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr); + _TLIST_REMOVE(ptr_tc->refs, handle); return 0; } @@ -255,16 +265,16 @@ static int talloc_reference_destructor(void *ptr) same underlying data, and you want to be able to free the two instances separately, and in either order */ -void *talloc_reference(const void *context, const void *ptr) +void *_talloc_reference(const void *context, const void *ptr) { struct talloc_chunk *tc; struct talloc_reference_handle *handle; if (ptr == NULL) return NULL; tc = talloc_chunk_from_ptr(ptr); - handle = (struct talloc_reference_handle *)talloc_named_const( - context, sizeof(*handle), TALLOC_MAGIC_REFERENCE); - + handle = (struct talloc_reference_handle *)talloc_named_const(context, + sizeof(struct talloc_reference_handle), + TALLOC_MAGIC_REFERENCE); if (handle == NULL) return NULL; /* note that we hang the destructor off the handle, not the @@ -302,10 +312,7 @@ static int talloc_unreference(const void *context, const void *ptr) return -1; } - talloc_set_destructor(h, NULL); - _TLIST_REMOVE(tc->refs, h); - talloc_free(h); - return 0; + return talloc_free(h); } /* @@ -364,26 +371,29 @@ int talloc_unlink(const void *context, void *ptr) /* add a name to an existing pointer - va_list version */ -static void talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +static const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -static void talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) +static const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) { struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); tc->name = talloc_vasprintf(ptr, fmt, ap); if (tc->name) { talloc_set_name_const(tc->name, ".name"); } + return tc->name; } /* add a name to an existing pointer */ -void talloc_set_name(const void *ptr, const char *fmt, ...) +const char *talloc_set_name(const void *ptr, const char *fmt, ...) { + const char *name; va_list ap; va_start(ap, fmt); - talloc_set_name_v(ptr, fmt, ap); + name = talloc_set_name_v(ptr, fmt, ap); va_end(ap); + return name; } /* @@ -405,14 +415,20 @@ void *talloc_named(const void *context, size_t size, const char *fmt, ...) { va_list ap; void *ptr; + const char *name; ptr = _talloc(context, size); if (ptr == NULL) return NULL; va_start(ap, fmt); - talloc_set_name_v(ptr, fmt, ap); + name = talloc_set_name_v(ptr, fmt, ap); va_end(ap); + if (name == NULL) { + talloc_free(ptr); + return NULL; + } + return ptr; } @@ -474,16 +490,20 @@ void *talloc_init(const char *fmt, ...) { va_list ap; void *ptr; - - talloc_enable_null_tracking(); + const char *name; ptr = _talloc(NULL, 0); if (ptr == NULL) return NULL; va_start(ap, fmt); - talloc_set_name_v(ptr, fmt, ap); + name = talloc_set_name_v(ptr, fmt, ap); va_end(ap); + if (name == NULL) { + talloc_free(ptr); + return NULL; + } + return ptr; } @@ -535,6 +555,7 @@ void talloc_free_children(void *ptr) int talloc_free(void *ptr) { struct talloc_chunk *tc; + int old_errno; if (ptr == NULL) { return -1; @@ -544,9 +565,15 @@ int talloc_free(void *ptr) if (tc->refs) { int is_child; - struct talloc_reference_handle *handle = tc->refs; - is_child = talloc_is_parent(handle, (const char *)handle->ptr); - talloc_reference_destructor(tc->refs); + /* check this is a reference from a child or grantchild + * back to it's parent or grantparent + * + * in that case we need to remove the reference and + * call another instance of talloc_free() on the current + * pointer. + */ + is_child = talloc_is_parent(tc->refs, ptr); + talloc_free(tc->refs); if (is_child) { return talloc_free(ptr); } @@ -571,10 +598,6 @@ int talloc_free(void *ptr) tc->destructor = NULL; } - tc->flags |= TALLOC_FLAG_LOOP; - - talloc_free_children(ptr); - if (tc->parent) { _TLIST_REMOVE(tc->parent->child, tc); if (tc->parent->child) { @@ -585,9 +608,13 @@ int talloc_free(void *ptr) if (tc->next) tc->next->prev = tc->prev; } - tc->flags |= TALLOC_FLAG_FREE; + tc->flags |= TALLOC_FLAG_LOOP; + talloc_free_children(ptr); + tc->flags |= TALLOC_FLAG_FREE; + old_errno = errno; free(tc); + errno = old_errno; return 0; } @@ -644,10 +671,10 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n tc = (struct talloc_chunk *)new_ptr; tc->flags &= ~TALLOC_FLAG_FREE; if (tc->parent) { - tc->parent->child = (struct talloc_chunk *)new_ptr; + tc->parent->child = tc; } if (tc->child) { - tc->child->parent = (struct talloc_chunk *)new_ptr; + tc->child->parent = tc; } if (tc->prev) { @@ -668,7 +695,7 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n ptr on success, or NULL if it could not be transferred. passing NULL as ptr will always return NULL with no side effects. */ -static void *talloc_steal(const void *new_ctx, const void *ptr) +void *_talloc_steal(const void *new_ctx, const void *ptr) { struct talloc_chunk *tc, *new_tc; @@ -723,11 +750,11 @@ static void *talloc_steal(const void *new_ctx, const void *ptr) /* return the total size of a talloc pool (subtree) */ -off_t talloc_total_size(const void *ptr) +size_t talloc_total_size(const void *ptr) { - off_t total = 0; + size_t total = 0; struct talloc_chunk *c, *tc; - + if (ptr == NULL) { ptr = null_context; } @@ -756,9 +783,9 @@ off_t talloc_total_size(const void *ptr) /* return the total number of blocks in a talloc pool (subtree) */ -off_t talloc_total_blocks(const void *ptr) +size_t talloc_total_blocks(const void *ptr) { - off_t total = 0; + size_t total = 0; struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); if (tc->flags & TALLOC_FLAG_LOOP) { @@ -780,11 +807,11 @@ off_t talloc_total_blocks(const void *ptr) /* return the number of external references to a pointer */ -static int talloc_reference_count(const void *ptr) +size_t talloc_reference_count(const void *ptr) { struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); struct talloc_reference_handle *h; - int ret = 0; + size_t ret = 0; for (h=tc->refs;h;h=h->next) { ret++; @@ -795,81 +822,93 @@ static int talloc_reference_count(const void *ptr) /* report on memory usage by all children of a pointer, giving a full tree view */ -void talloc_report_depth(const void *ptr, FILE *f, int depth) +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) { - struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); + struct talloc_chunk *c, *tc; + + if (ptr == NULL) { + ptr = null_context; + } + if (ptr == NULL) return; + + tc = talloc_chunk_from_ptr(ptr); if (tc->flags & TALLOC_FLAG_LOOP) { return; } - tc->flags |= TALLOC_FLAG_LOOP; + callback(ptr, depth, max_depth, 0, private_data); + + if (max_depth >= 0 && depth >= max_depth) { + return; + } + tc->flags |= TALLOC_FLAG_LOOP; for (c=tc->child;c;c=c->next) { if (c->name == TALLOC_MAGIC_REFERENCE) { - struct talloc_reference_handle *handle = - (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c); - const char *name2 = talloc_get_name(handle->ptr); - fprintf(f, "%*sreference to: %s\n", depth*4, "", name2); + struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c); + callback(h->ptr, depth + 1, max_depth, 1, private_data); } else { - const char *name = talloc_get_name(TC_PTR_FROM_CHUNK(c)); - fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d)\n", - depth*4, "", - name, - (unsigned long)talloc_total_size(TC_PTR_FROM_CHUNK(c)), - (unsigned long)talloc_total_blocks(TC_PTR_FROM_CHUNK(c)), - talloc_reference_count(TC_PTR_FROM_CHUNK(c))); - talloc_report_depth(TC_PTR_FROM_CHUNK(c), f, depth+1); + talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data); } } tc->flags &= ~TALLOC_FLAG_LOOP; } -/* - report on memory usage by all children of a pointer, giving a full tree view -*/ -void talloc_report_full(const void *ptr, FILE *f) +static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f) { - if (ptr == NULL) { - ptr = null_context; + const char *name = talloc_get_name(ptr); + FILE *f = (FILE *)_f; + + if (is_ref) { + fprintf(f, "%*sreference to: %s\n", depth*4, "", name); + return; + } + + if (depth == 0) { + fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", + (max_depth < 0 ? "full " :""), name, + (unsigned long)talloc_total_size(ptr), + (unsigned long)talloc_total_blocks(ptr)); + return; } - if (ptr == NULL) return; - fprintf(f,"full talloc report on '%s' (total %lu bytes in %lu blocks)\n", - talloc_get_name(ptr), + fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d)\n", + depth*4, "", + name, (unsigned long)talloc_total_size(ptr), - (unsigned long)talloc_total_blocks(ptr)); + (unsigned long)talloc_total_blocks(ptr), + talloc_reference_count(ptr)); +} - talloc_report_depth(ptr, f, 1); +/* + report on memory usage by all children of a pointer, giving a full tree view +*/ +void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f) +{ + talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f); fflush(f); } /* + report on memory usage by all children of a pointer, giving a full tree view +*/ +void talloc_report_full(const void *ptr, FILE *f) +{ + talloc_report_depth_file(ptr, 0, -1, f); +} + +/* report on memory usage by all children of a pointer */ void talloc_report(const void *ptr, FILE *f) { - struct talloc_chunk *c, *tc; - - if (ptr == NULL) { - ptr = null_context; - } - if (ptr == NULL) return; - - fprintf(f,"talloc report on '%s' (total %lu bytes in %lu blocks)\n", - talloc_get_name(ptr), - (unsigned long)talloc_total_size(ptr), - (unsigned long)talloc_total_blocks(ptr)); - - tc = talloc_chunk_from_ptr(ptr); - - for (c=tc->child;c;c=c->next) { - fprintf(f, "\t%-30s contains %6lu bytes in %3lu blocks\n", - talloc_get_name(TC_PTR_FROM_CHUNK(c)), - (unsigned long)talloc_total_size(TC_PTR_FROM_CHUNK(c)), - (unsigned long)talloc_total_blocks(TC_PTR_FROM_CHUNK(c))); - } - fflush(f); + talloc_report_depth_file(ptr, 0, 1, f); } /* @@ -893,16 +932,6 @@ static void talloc_report_null_full(void) } /* - free allocated global memory -*/ - -void talloc_nc_free(void) -{ - if ( null_context ) - talloc_free( (void*)null_context ); -} - -/* enable tracking of the NULL context */ void talloc_enable_null_tracking(void) @@ -912,76 +941,16 @@ void talloc_enable_null_tracking(void) } } -#ifdef _SAMBA_BUILD_ -/* Ugly calls to Samba-specific sprintf_append... JRA. */ - /* - report on memory usage by all children of a pointer, giving a full tree view + disable tracking of the NULL context */ -static void talloc_report_depth_str(const void *ptr, char **pps, ssize_t *plen, size_t *pbuflen, int depth) +void talloc_disable_null_tracking(void) { - struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); - - if (tc->flags & TALLOC_FLAG_LOOP) { - return; - } - - tc->flags |= TALLOC_FLAG_LOOP; - - for (c=tc->child;c;c=c->next) { - if (c->name == TALLOC_MAGIC_REFERENCE) { - struct talloc_reference_handle *handle = - (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c); - const char *name2 = talloc_get_name(handle->ptr); - - sprintf_append(NULL, pps, plen, pbuflen, - "%*sreference to: %s\n", depth*4, "", name2); - - } else { - const char *name = talloc_get_name(TC_PTR_FROM_CHUNK(c)); - - sprintf_append(NULL, pps, plen, pbuflen, - "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d)\n", - depth*4, "", - name, - (unsigned long)talloc_total_size(TC_PTR_FROM_CHUNK(c)), - (unsigned long)talloc_total_blocks(TC_PTR_FROM_CHUNK(c)), - talloc_reference_count(TC_PTR_FROM_CHUNK(c))); - - talloc_report_depth_str(TC_PTR_FROM_CHUNK(c), pps, plen, pbuflen, depth+1); - } - } - tc->flags &= ~TALLOC_FLAG_LOOP; + talloc_free(null_context); + null_context = NULL; } /* - report on memory usage by all children of a pointer -*/ -char *talloc_describe_all(void) -{ - ssize_t len = 0; - size_t buflen = 512; - char *s = NULL; - - if (null_context == NULL) { - return NULL; - } - - sprintf_append(NULL, &s, &len, &buflen, - "full talloc report on '%s' (total %lu bytes in %lu blocks)\n", - talloc_get_name(null_context), - (unsigned long)talloc_total_size(null_context), - (unsigned long)talloc_total_blocks(null_context)); - - if (!s) { - return NULL; - } - talloc_report_depth_str(null_context, &s, &len, &buflen, 1); - return s; -} -#endif - -/* enable leak reporting on exit */ void talloc_enable_leak_report(void) @@ -1086,13 +1055,11 @@ char *talloc_strndup(const void *t, const char *p, size_t n) return ret; } -#ifndef VA_COPY -#ifdef HAVE_VA_COPY -#define VA_COPY(dest, src) va_copy(dest, src) -#elif defined(HAVE___VA_COPY) -#define VA_COPY(dest, src) __va_copy(dest, src) +#ifndef HAVE_VA_COPY +#ifdef HAVE___VA_COPY +#define va_copy(dest, src) __va_copy(dest, src) #else -#define VA_COPY(dest, src) (dest) = (src) +#define va_copy(dest, src) (dest) = (src) #endif #endif @@ -1103,7 +1070,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) va_list ap2; char c; - VA_COPY(ap2, ap); + va_copy(ap2, ap); /* this call looks strange, but it makes it work on older solaris boxes */ if ((len = vsnprintf(&c, 1, fmt, ap2)) < 0) { @@ -1112,7 +1079,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) ret = (char *)_talloc(t, len+1); if (ret) { - VA_COPY(ap2, ap); + va_copy(ap2, ap); vsnprintf(ret, len+1, fmt, ap2); talloc_set_name_const(ret, ret); } @@ -1142,12 +1109,12 @@ char *talloc_asprintf(const void *t, const char *fmt, ...) * and return @p s, which may have moved. Good for gradually * accumulating output into a string buffer. **/ - char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) { struct talloc_chunk *tc; int len, s_len; va_list ap2; + char c; if (s == NULL) { return talloc_vasprintf(NULL, fmt, ap); @@ -1155,10 +1122,10 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) tc = talloc_chunk_from_ptr(s); - VA_COPY(ap2, ap); + va_copy(ap2, ap); s_len = tc->size - 1; - if ((len = vsnprintf(NULL, 0, fmt, ap2)) <= 0) { + if ((len = vsnprintf(&c, 1, fmt, ap2)) <= 0) { /* Either the vsnprintf failed or the format resulted in * no characters being formatted. In the former case, we * ought to return NULL, in the latter we ought to return @@ -1171,7 +1138,7 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) s = talloc_realloc(NULL, s, char, s_len + len+1); if (!s) return NULL; - VA_COPY(ap2, ap); + va_copy(ap2, ap); vsnprintf(s+s_len, len+1, fmt, ap2); talloc_set_name_const(s, s); @@ -1290,7 +1257,6 @@ void *talloc_find_parent_byname(const void *context, const char *name) if (tc) { tc = tc->parent; } - } return NULL; } @@ -1321,7 +1287,7 @@ void talloc_show_parents(const void *context, FILE *file) /* return 1 if ptr is a parent of context */ -int talloc_is_parent(const void *context, const char *ptr) +int talloc_is_parent(const void *context, const void *ptr) { struct talloc_chunk *tc; diff --git a/source3/lib/tallocmsg.c b/source3/lib/tallocmsg.c index e4364f1ff7..599d60737d 100644 --- a/source3/lib/tallocmsg.c +++ b/source3/lib/tallocmsg.c @@ -25,6 +25,40 @@ * Glue code between talloc profiling and the Samba messaging system. **/ +struct msg_pool_usage_state { + ssize_t len; + size_t buflen; + char *s; +}; + +static void msg_pool_usage_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_s) +{ + const char *name = talloc_get_name(ptr); + struct msg_pool_usage_state *state = (struct msg_pool_usage_state *)_s; + + if (is_ref) { + sprintf_append(NULL, &state->s, &state->len, &state->buflen, + "%*sreference to: %s\n", depth*4, "", name); + return; + } + + if (depth == 0) { + sprintf_append(NULL, &state->s, &state->len, &state->buflen, + "%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", + (max_depth < 0 ? "full " :""), name, + (unsigned long)talloc_total_size(ptr), + (unsigned long)talloc_total_blocks(ptr)); + return; + } + + sprintf_append(NULL, &state->s, &state->len, &state->buflen, + "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d)\n", + depth*4, "", + name, + (unsigned long)talloc_total_size(ptr), + (unsigned long)talloc_total_blocks(ptr), + talloc_reference_count(ptr)); +} /** * Respond to a POOL_USAGE message by sending back string form of memory @@ -33,21 +67,26 @@ void msg_pool_usage(int msg_type, struct process_id src_pid, void *UNUSED(buf), size_t UNUSED(len)) { - char *reply = NULL; + struct msg_pool_usage_state state; SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE); DEBUG(2,("Got POOL_USAGE\n")); - reply = talloc_describe_all(); - if (!reply) { + state.len = 0; + state.buflen = 512; + state.s = NULL; + + talloc_report_depth_cb(NULL, 0, -1, msg_pool_usage_helper, &state); + + if (!state.s) { return; } message_send_pid(src_pid, MSG_POOL_USAGE, - reply, strlen(reply)+1, True); + state.s, strlen(state.s)+1, True); - SAFE_FREE(reply); + SAFE_FREE(state.s); } /** diff --git a/source3/lib/util.c b/source3/lib/util.c index 20ff4514a0..d650d0ed8b 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -202,7 +202,7 @@ void gfree_all( void ) gfree_messages(); /* release the talloc null_context memory last */ - talloc_nc_free(); + talloc_disable_null_tracking(); } const char *my_netbios_names(int i) |