git-2.22.0/builtin/pack-redundant.c
/* Sort pack_list, greater size of remaining_objects first */
Sort pack_list, greater size of remaining_objects first
Sort pack_list greater size of remaining_objects first
static void sort_pack_list(struct pack_list **pl)
{
	struct pack_list **ary, *p;
	int i;
	size_t n = pack_list_size(*pl);
	if (n < 2)
		return;
	ary = xcalloc(n, sizeof(struct pack_list *));
	for (n = 0, p = *pl; p; p = p->next)
		ary[n++] = p;
	QSORT(ary, n, cmp_remaining_objects);
	for (i = 0; i < n - 1; i++)
		ary[i]->next = ary[i + 1];
	ary[n - 1]->next = NULL;
	*pl = ary[0];
	free(ary);
}
static void sort_pack_list ( struct pack_list * * pl ) { struct pack_list * * ary , * p ; int i ; size_t n = pack_list_size ( * pl ) ; if ( n < 2 ) return ; ary = xcalloc ( n , sizeof ( struct pack_list * ) ) ; for ( n = 0 , p = * pl ; p ; p = p -> next ) ary [ n ++ ] = p ; QSORT ( ary , n , cmp_remaining_objects ) ; for ( i = 0 ; i < n - 1 ; i ++ ) ary [ i ] -> next = ary [ i + 1 ] ; ary [ n - 1 ] -> next = NULL ; * pl = ary [ 0 ] ; free ( ary ) ; }
Sort pack_list, greater size of remaining_objects first
Sort pack_list greater size of remaining_objects first
/* prepare an array of packed_list for easier sorting */ /* link them back again */