testing/icgen/random_verschillende_resoluties_N-GenIC/gadget3_64/subfind_loctree.c
size_t subfind_loctree_treeallocate(int maxnodes, int maxpart)	/* usually maxnodes=0.7*maxpart is sufficient */
{
  size_t bytes, allbytes = 0;

  MaxNodes = maxnodes;

  if(!(Nodes_base = mymalloc(bytes = (MaxNodes + 1) * sizeof(struct NODE))))
    {
      printf("failed to allocate memory for %d tree-nodes (%g MB).\n", MaxNodes, bytes / (1024.0 * 1024.0));
      endrun(3);
    }
  allbytes += bytes;

  if(!(Nextnode = mymalloc(bytes = maxpart * sizeof(int))))
    {
      printf("Failed to allocate %d spaces for 'Nextnode' array (%g MB)\n", maxpart,
	     bytes / (1024.0 * 1024.0));
      endrun(4);
    }
  allbytes += bytes;

  if(!(Father = mymalloc(bytes = maxpart * sizeof(int))))
    {
      printf("Failed to allocate %d spaces for 'Father' array (%g MB)\n", maxpart, bytes / (1024.0 * 1024.0));
      endrun(5);
    }
  allbytes += bytes;

  if(!(R2list = mymalloc(bytes = maxpart * sizeof(struct r2data))))
    {
      printf("failed to allocate memory for R2list\n");
      endrun(3);
    }

  allbytes += bytes;

  Nodes = Nodes_base - All.MaxPart;

  return allbytes;
}
/* this function allocates memory used for storage of the tree
 * and auxiliary arrays for tree-walk and link-lists.
 */
this function allocates memory used for storage of the tree
and auxiliary arrays for tree-walk and link-lists.
this function allocates memory used for storage of the tree and auxiliary arrays for tree - walk and link - lists .
size_t subfind_loctree_treeallocate(int maxnodes, int maxpart)	
{
  size_t bytes, allbytes = 0;
  MaxNodes = maxnodes;
  if(!(Nodes_base = mymalloc(bytes = (MaxNodes + 1) * sizeof(struct NODE))))
    {
      printf("failed to allocate memory for %d tree-nodes (%g MB).\n", MaxNodes, bytes / (1024.0 * 1024.0));
      endrun(3);
    }
  allbytes += bytes;
  if(!(Nextnode = mymalloc(bytes = maxpart * sizeof(int))))
    {
      printf("Failed to allocate %d spaces for 'Nextnode' array (%g MB)\n", maxpart,
	     bytes / (1024.0 * 1024.0));
      endrun(4);
    }
  allbytes += bytes;
  if(!(Father = mymalloc(bytes = maxpart * sizeof(int))))
    {
      printf("Failed to allocate %d spaces for 'Father' array (%g MB)\n", maxpart, bytes / (1024.0 * 1024.0));
      endrun(5);
    }
  allbytes += bytes;
  if(!(R2list = mymalloc(bytes = maxpart * sizeof(struct r2data))))
    {
      printf("failed to allocate memory for R2list\n");
      endrun(3);
    }
  allbytes += bytes;
  Nodes = Nodes_base - All.MaxPart;
  return allbytes;
}
size_t subfind_loctree_treeallocate ( int maxnodes , int maxpart ) { size_t bytes , allbytes = 0 ; MaxNodes = maxnodes ; if ( ! ( Nodes_base = mymalloc ( bytes = ( MaxNodes + 1 ) * sizeof ( struct NODE ) ) ) ) { printf ( " \n " , MaxNodes , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 3 ) ; } allbytes += bytes ; if ( ! ( Nextnode = mymalloc ( bytes = maxpart * sizeof ( int ) ) ) ) { printf ( " \n " , maxpart , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 4 ) ; } allbytes += bytes ; if ( ! ( Father = mymalloc ( bytes = maxpart * sizeof ( int ) ) ) ) { printf ( " \n " , maxpart , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 5 ) ; } allbytes += bytes ; if ( ! ( R2list = mymalloc ( bytes = maxpart * sizeof ( struct r2data ) ) ) ) { printf ( " \n " ) ; endrun ( 3 ) ; } allbytes += bytes ; Nodes = Nodes_base - All . MaxPart ; return allbytes ; }
this function allocates memory used for storage of the tree
 and auxiliary arrays for tree-walk and link-lists.
this function allocates memory used for storage of the tree and auxiliary arrays for tree - walk and link - lists .
/* usually maxnodes=0.7*maxpart is sufficient */