/** * @brief Creates and initializes * the binary tree of all file blocks. * @return Zero for success, * negative value otherwise. * @note jp->file_blocks must be * initialized by NULL or contain * pointer to a valid tree before * this call. */ int create_file_blocks_tree(udefrag_job_parameters *jp) { itrace("create_file_blocks_tree called"); if(jp->file_blocks) destroy_file_blocks_tree(jp); jp->file_blocks = prb_create(blocks_compare,NULL,NULL); return 0; }
/** * @brief Produces list of fragmented files. */ static void produce_list_of_fragmented_files(udefrag_job_parameters *jp) { winx_file_info *f; ULONGLONG bad_fragments = 0; ULONGLONG bad_clusters = 0; itrace("started creation of fragmented files list"); jp->fragmented_files = prb_create(fragmented_files_compare,(void *)jp,NULL); for(f = jp->filelist; f; f = f->next){ if(is_fragmented(f) && !is_excluded(f)){ expand_fragmented_files_list(f,jp); //Old way counts number of fragments and calculates percentage on // how many TOTAL fragments exist. Seems very inaccurate... bad_fragments += f->disp.fragments; bad_clusters += f->disp.clusters; //use clusters instead. } if(f->next == jp->filelist) break; } jp->pi.bad_fragments = bad_fragments; jp->pi.bad_clusters = bad_clusters; jp->pi.fragmented_files_prb = jp->fragmented_files; //pointer for fileslist.cpp to access jp->pi.isfragfileslist = 1; itrace("finished creation of fragmented files list"); itrace("fragments total: %u",jp->pi.fragments); itrace("bad_clusters : %u",jp->pi.bad_clusters); }
/* Tests tree functions. |insert[]| and |delete[]| must contain some permutation of values |0|@dots{}|n - 1|. Uses |allocator| as the allocator for tree and node data. Higher values of |verbosity| produce more debug output. */ int test_correctness (struct libavl_allocator *allocator, int insert[], int delete[], int n, int verbosity) { struct prb_table *tree; int okay = 1; int i; /* Test creating a PRB and inserting into it. */ tree = prb_create (compare_ints, NULL, allocator); if (tree == NULL) { if (verbosity >= 0) printf (" Out of memory creating tree.\n"); return 1; } for (i = 0; i < n; i++) { if (verbosity >= 2) printf (" Inserting %d...\n", insert[i]); /* Add the |i|th element to the tree. */ { void **p = prb_probe (tree, &insert[i]);