s3: For "smbcontrol <pid> pool-usage", print the first 50 bytes of a string
authorVolker Lendecke <vl@samba.org>
Sun, 17 Jan 2010 13:57:54 +0000 (14:57 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 17 Jan 2010 14:04:25 +0000 (15:04 +0100)
source3/lib/tallocmsg.c

index adeb4ed8d6c28fe54d5b3912d588d471a4f5ae12..3cfd118d21cb811c7e29f52fd172b845a473c29f 100644 (file)
@@ -51,6 +51,23 @@ static void msg_pool_usage_helper(const void *ptr, int depth, int max_depth, int
                return;
        }
 
+       if (strcmp(name, "char") == 0) {
+               /*
+                * Print out the first 50 bytes of the string
+                */
+               sprintf_append(state->mem_ctx, &state->s, &state->len,
+                              &state->buflen,
+                              "%*s%-30s contains %6lu bytes in %3lu blocks "
+                              "(ref %d): %*s\n", depth*4, "",
+                              name,
+                              (unsigned long)talloc_total_size(ptr),
+                              (unsigned long)talloc_total_blocks(ptr),
+                              talloc_reference_count(ptr),
+                              MIN(50, talloc_get_size(ptr)),
+                              (char *)ptr);
+               return;
+       }
+
        sprintf_append(state->mem_ctx, &state->s, &state->len, &state->buflen,
                       "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d)\n", 
                       depth*4, "",