summaryrefslogtreecommitdiff
path: root/lib/talloc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-07-13 18:51:24 +0200
committerAndrew Tridgell <tridge@samba.org>2009-08-24 16:29:57 +1000
commitd1895d2fee9eec6f0b16dd38728b34d2f8233b0c (patch)
tree20b4568bd25991a886e876c00cf868832c0dc005 /lib/talloc
parentfced9dfc1ea45f902e9281679f479ae18d229c17 (diff)
downloadsamba-d1895d2fee9eec6f0b16dd38728b34d2f8233b0c.tar.gz
samba-d1895d2fee9eec6f0b16dd38728b34d2f8233b0c.tar.bz2
samba-d1895d2fee9eec6f0b16dd38728b34d2f8233b0c.zip
talloc: let talloc_total_blocks() and talloc_get_size() operate on the null_context
metze
Diffstat (limited to 'lib/talloc')
-rw-r--r--lib/talloc/talloc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 0126567c45..8e91b60c99 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1227,7 +1227,16 @@ size_t talloc_total_size(const void *ptr)
size_t talloc_total_blocks(const void *ptr)
{
size_t total = 0;
- 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 0;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
if (tc->flags & TALLOC_FLAG_LOOP) {
return 0;
@@ -1807,8 +1816,12 @@ size_t talloc_get_size(const void *context)
{
struct talloc_chunk *tc;
- if (context == NULL)
+ if (context == NULL) {
+ context = null_context;
+ }
+ if (context == NULL) {
return 0;
+ }
tc = talloc_chunk_from_ptr(context);