library/src/mmap/BP-MMapSlabAllocator.cc
BP_SLAB_ALLOCATOR_ITER_LOOP_ALL(allocator)
	{


		// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		// %%% Keep Track of Empties %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

		// ensure we have a group top
		if(!group_top_was_found)
		{
			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_AVAILABLE))
			{
				empty_chunks_before_first_group_n++;
				continue;
			}
		}


		// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		// %%% Perform Counts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


		if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_IS_GROUP_TOP))
		{

			// increment group top iter on detection of group top iteratoro
			group_top_iter_n++;

			// set the defrag top pointer
			defrag_info_entries[group_top_iter_n-1].group_alloc_top_ptr = allocator->curr_entry;

			// if the next is part of a group, indicate so here
			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED))
				next_is_grouped = BP_TRUE;

			// display group top message
			printf("\n [+] - %u - Group Top %p", entry_iter_n, defrag_info_entries[group_top_iter_n-1].group_alloc_top_ptr);

			// increase the allocated chunk count
			defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;

			// ensure you have a group top
			if(!group_top_was_found)
			{

				// mark as first
				defrag_info_entries[group_top_iter_n-1].is_first_group_entry = BP_TRUE;

				// set the empty chunks entry
				defrag_info_entries[group_top_iter_n-1].if_first_how_many_empty_before = empty_chunks_before_first_group_n;

				// set the group top indicator toggle
				group_top_was_found=BP_TRUE;

			}

		}
		else
		{


			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED))
			{


				// verbosity
				printf("\n - %u - Advancing group iter!", entry_iter_n);

				// increase the allocated chunk count
				defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;

			}
			else if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_PREV_IS_GROUPED))
			{

				// verbosity
				printf("\n - %u - Encountered final group entry!", entry_iter_n);

				// increase the allocated chunk count
				defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;
			}
			else
			{

				if(group_top_was_found == BP_TRUE)
					defrag_info_entries[group_top_iter_n-1].trailing_available_alloc_n++;

				// verbosity
				printf("\n - %u - Advancing available alloc iter.", entry_iter_n);


				// remove the presumption that the next entry is grouped
				next_is_grouped = BP_FALSE;

			}

		}


		// if a group top was not found, go ahead and update here
		if(!group_top_was_found)
			entries_till_first_group_hdr_n++;

		// increment the iterator
		entry_iter_n++;

	}
// Loop through all entries, updating the allocator with relevant data on each loop count.
Loop through all entries, updating the allocator with relevant data on each loop count.
Loop through all entries updating the allocator with relevant data on each loop count .
BP_SLAB_ALLOCATOR_ITER_LOOP_ALL(allocator)
	{
		if(!group_top_was_found)
		{
			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_AVAILABLE))
			{
				empty_chunks_before_first_group_n++;
				continue;
			}
		}
		if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_IS_GROUP_TOP))
		{
			group_top_iter_n++;
			defrag_info_entries[group_top_iter_n-1].group_alloc_top_ptr = allocator->curr_entry;
			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED))
				next_is_grouped = BP_TRUE;
			printf("\n [+] - %u - Group Top %p", entry_iter_n, defrag_info_entries[group_top_iter_n-1].group_alloc_top_ptr);
			defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;
			if(!group_top_was_found)
			{
				defrag_info_entries[group_top_iter_n-1].is_first_group_entry = BP_TRUE;
				defrag_info_entries[group_top_iter_n-1].if_first_how_many_empty_before = empty_chunks_before_first_group_n;
				group_top_was_found=BP_TRUE;
			}
		}
		else
		{
			if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED))
			{
				printf("\n - %u - Advancing group iter!", entry_iter_n);
				defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;
			}
			else if(BP_FLAG_IS_SET(allocator->curr_entry->flags, BP_MMAP_SLAB_ENTRY_INFO_PREV_IS_GROUPED))
			{
				printf("\n - %u - Encountered final group entry!", entry_iter_n);
				defrag_info_entries[group_top_iter_n-1].group_alloc_chunks_n++;
			}
			else
			{
				if(group_top_was_found == BP_TRUE)
					defrag_info_entries[group_top_iter_n-1].trailing_available_alloc_n++;
				printf("\n - %u - Advancing available alloc iter.", entry_iter_n);
				next_is_grouped = BP_FALSE;
			}
		}
		if(!group_top_was_found)
			entries_till_first_group_hdr_n++;
		entry_iter_n++;
	}
BP_SLAB_ALLOCATOR_ITER_LOOP_ALL ( allocator ) { if ( ! group_top_was_found ) { if ( BP_FLAG_IS_SET ( allocator -> curr_entry -> flags , BP_MMAP_SLAB_ENTRY_INFO_AVAILABLE ) ) { empty_chunks_before_first_group_n ++ ; continue ; } } if ( BP_FLAG_IS_SET ( allocator -> curr_entry -> flags , BP_MMAP_SLAB_ENTRY_INFO_IS_GROUP_TOP ) ) { group_top_iter_n ++ ; defrag_info_entries [ group_top_iter_n - 1 ] . group_alloc_top_ptr = allocator -> curr_entry ; if ( BP_FLAG_IS_SET ( allocator -> curr_entry -> flags , BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED ) ) next_is_grouped = BP_TRUE ; printf ( " \n " , entry_iter_n , defrag_info_entries [ group_top_iter_n - 1 ] . group_alloc_top_ptr ) ; defrag_info_entries [ group_top_iter_n - 1 ] . group_alloc_chunks_n ++ ; if ( ! group_top_was_found ) { defrag_info_entries [ group_top_iter_n - 1 ] . is_first_group_entry = BP_TRUE ; defrag_info_entries [ group_top_iter_n - 1 ] . if_first_how_many_empty_before = empty_chunks_before_first_group_n ; group_top_was_found = BP_TRUE ; } } else { if ( BP_FLAG_IS_SET ( allocator -> curr_entry -> flags , BP_MMAP_SLAB_ENTRY_INFO_NEXT_IS_GROUPED ) ) { printf ( " \n " , entry_iter_n ) ; defrag_info_entries [ group_top_iter_n - 1 ] . group_alloc_chunks_n ++ ; } else if ( BP_FLAG_IS_SET ( allocator -> curr_entry -> flags , BP_MMAP_SLAB_ENTRY_INFO_PREV_IS_GROUPED ) ) { printf ( " \n " , entry_iter_n ) ; defrag_info_entries [ group_top_iter_n - 1 ] . group_alloc_chunks_n ++ ; } else { if ( group_top_was_found == BP_TRUE ) defrag_info_entries [ group_top_iter_n - 1 ] . trailing_available_alloc_n ++ ; printf ( " \n " , entry_iter_n ) ; next_is_grouped = BP_FALSE ; } } if ( ! group_top_was_found ) entries_till_first_group_hdr_n ++ ; entry_iter_n ++ ; }
Loop through all entries, updating the allocator with relevant data on each loop count.
Loop through all entries updating the allocator with relevant data on each loop count .
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Keep Track of Empties %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ensure we have a group top // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Perform Counts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // increment group top iter on detection of group top iteratoro // set the defrag top pointer // if the next is part of a group, indicate so here // display group top message // increase the allocated chunk count // ensure you have a group top // mark as first // set the empty chunks entry // set the group top indicator toggle // verbosity // increase the allocated chunk count // verbosity // increase the allocated chunk count // verbosity // remove the presumption that the next entry is grouped // if a group top was not found, go ahead and update here // increment the iterator