src/lib/tree.c
TREE_ROOT *new_tree(int count)
{
   TREE_ROOT *root;
   uint32_t size;

   if (count < 1000) {                /* minimum tree size */
      count = 1000;
   }
   root = (TREE_ROOT *)malloc(sizeof(TREE_ROOT));
   bmemset(root, 0, sizeof(TREE_ROOT));
   /* Assume filename + node  = 40 characters average length */
   size = count * (BALIGN(sizeof(TREE_NODE)) + 40);
   if (count > 1000000 || size > (MAX_BUF_SIZE / 2)) {
      size = MAX_BUF_SIZE;
   }
   Dmsg2(400, "count=%d size=%d\n", count, size);
   malloc_buf(root, size);
   root->cached_path_len = -1;
   root->cached_path = get_pool_memory(PM_FNAME);
   root->type = TN_ROOT;
   root->fname = "";
   root->can_access = 1;
   HL_ENTRY* entry = NULL;
   root->hardlinks.init(entry, &entry->link, 0);
   return root;
}
/*
 * Note, we allocate a big buffer in the tree root
 *  from which we allocate nodes. This runs more
 *  than 100 times as fast as directly using malloc()
 *  for each of the nodes.
 */
Note, we allocate a big buffer in the tree root
from which we allocate nodes. This runs more
than 100 times as fast as directly using malloc()
for each of the nodes.
Note we allocate a big buffer in the tree root from which we allocate nodes . This runs more than 100 times as fast as directly using malloc () for each of the nodes .
TREE_ROOT *new_tree(int count)
{
   TREE_ROOT *root;
   uint32_t size;
   if (count < 1000) {                
      count = 1000;
   }
   root = (TREE_ROOT *)malloc(sizeof(TREE_ROOT));
   bmemset(root, 0, sizeof(TREE_ROOT));
   size = count * (BALIGN(sizeof(TREE_NODE)) + 40);
   if (count > 1000000 || size > (MAX_BUF_SIZE / 2)) {
      size = MAX_BUF_SIZE;
   }
   Dmsg2(400, "count=%d size=%d\n", count, size);
   malloc_buf(root, size);
   root->cached_path_len = -1;
   root->cached_path = get_pool_memory(PM_FNAME);
   root->type = TN_ROOT;
   root->fname = "";
   root->can_access = 1;
   HL_ENTRY* entry = NULL;
   root->hardlinks.init(entry, &entry->link, 0);
   return root;
}
TREE_ROOT * new_tree ( int count ) { TREE_ROOT * root ; uint32_t size ; if ( count < 1000 ) { count = 1000 ; } root = ( TREE_ROOT * ) malloc ( sizeof ( TREE_ROOT ) ) ; bmemset ( root , 0 , sizeof ( TREE_ROOT ) ) ; size = count * ( BALIGN ( sizeof ( TREE_NODE ) ) + 40 ) ; if ( count > 1000000 || size > ( MAX_BUF_SIZE / 2 ) ) { size = MAX_BUF_SIZE ; } Dmsg2 ( 400 , " \n " , count , size ) ; malloc_buf ( root , size ) ; root -> cached_path_len = -1 ; root -> cached_path = get_pool_memory ( PM_FNAME ) ; root -> type = TN_ROOT ; root -> fname = " " ; root -> can_access = 1 ; HL_ENTRY * entry = NULL ; root -> hardlinks . init ( entry , & entry -> link , 0 ) ; return root ; }
Note, we allocate a big buffer in the tree root
  from which we allocate nodes.
Note we allocate a big buffer in the tree root from which we allocate nodes .
/* minimum tree size */ /* Assume filename + node  = 40 characters average length */