Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

char* talloc_describe_all ( TALLOC_CTX rt  ) 

Return a human-readable description of all talloc memory usage. The result is allocated from t.

Definition at line 372 of file talloc.c.

References list_head, talloc_asprintf(), talloc_asprintf_append(), and talloc_get_allocation().

{
      int n_pools = 0, total_chunks = 0;
      size_t total_bytes = 0;
      TALLOC_CTX *it;
      char *s;

      if (!rt) return NULL;

      s = talloc_asprintf(rt, "global talloc allocations in pid: %u\n",
                      (unsigned) sys_getpid());
      s = talloc_asprintf_append(rt, s, "%-40s %8s %8s\n",
                           "name", "chunks", "bytes");
      s = talloc_asprintf_append(rt, s, "%-40s %8s %8s\n",
                           "----------------------------------------",
                           "--------",
                           "--------");   
      
      for (it = list_head; it; it = it->next_ctx) {
            size_t bytes;
            int n_chunks;
            fstring what;
            
            n_pools++;
            
            talloc_get_allocation(it, &bytes, &n_chunks);

            if (it->name)
                  fstrcpy(what, it->name);
            else
                  slprintf(what, sizeof what, "@%p", it);
            
            s = talloc_asprintf_append(rt, s, "%-40s %8u %8u\n",
                                 what,
                                 (unsigned) n_chunks,
                                 (unsigned) bytes);
            total_bytes += bytes;
            total_chunks += n_chunks;
      }

      s = talloc_asprintf_append(rt, s, "%-40s %8s %8s\n",
                           "----------------------------------------",
                           "--------",
                           "--------");   

      s = talloc_asprintf_append(rt, s, "%-40s %8u %8u\n",
                           "TOTAL",
                           (unsigned) total_chunks, (unsigned) total_bytes);

      return s;
}


Generated by  Doxygen 1.6.0   Back to index