} if (npartitions == 0) { *npart = 0; return(NULL);
sort_partitions(lp, npart)	struct disklabel *lp;	u_int16_t *npart;{	u_int16_t npartitions;	struct partition **spp;	int i;	/* How many "real" partitions do we have? */	for (npartitions = 0, i = 0; i < lp->d_npartitions; i++) {		if (lp->d_partitions[i].p_fstype != FS_UNUSED &&		    lp->d_partitions[i].p_fstype != FS_BOOT &&		    lp->d_partitions[i].p_size != 0)			npartitions++;	}	/* Create an array of pointers to the partition data */	if ((spp = malloc(sizeof(struct partition *) * npartitions)) == NULL)		errx(4, "out of memory");	for (npartitions = 0, i = 0; i < lp->d_npartitions; i++) {		if (lp->d_partitions[i].p_fstype != FS_UNUSED &&		    lp->d_partitions[i].p_fstype != FS_BOOT &&		    lp->d_partitions[i].p_size != 0)			spp[npartitions++] = &lp->d_partitions[i];	}	/*	 * Sort the partitions based on starting offset.	 * This is safe because we guarantee no overlap.	 */	if (npartitions > 1)		if (heapsort((void *)spp, npartitions, sizeof(spp[0]),		    partition_cmp))			err(4, "failed to sort partition table");	*npart = npartitions;	return(spp);}