protected StructurePackResult pack() {

		boolean componentsChanged = false;

		int componentCount = 0;

		AlignedComponentPacker packer =
			new AlignedComponentPacker(structure.getStoredPackingValue(), dataOrganization);

		// Remove any default components from list
		Iterator<? extends InternalDataTypeComponent> componentIterator = components.iterator();
		while (componentIterator.hasNext()) {
			InternalDataTypeComponent dataTypeComponent = componentIterator.next();
			DataType componentDt = dataTypeComponent.getDataType();
			if (DataType.DEFAULT == componentDt) {
				// transform improper DEFAULT datatype use to Undefined1
				dataTypeComponent.setDataType(Undefined1DataType.dataType);
				componentsChanged = true;
			}
			++componentCount;
		}

		int index = 0;
		for (InternalDataTypeComponent dataTypeComponent : components) {
			boolean isLastComponent = (++index == componentCount);
			packer.addComponent(dataTypeComponent, isLastComponent);
		}

		int defaultAlignment = packer.getDefaultAlignment();

		int length = packer.getLength();
		componentsChanged |= packer.componentsChanged();

		int alignment = defaultAlignment;
		AlignmentType alignmentType = structure.getAlignmentType();
		if (alignmentType != AlignmentType.DEFAULT) {
			// Apply minimum alignment if applicable - may be reduced by explicit pack
			// Simplified logic assumes pack and align values which are a power of 2 (1,2,4,8,16...)
			int minAlign =
				alignmentType == AlignmentType.MACHINE ? dataOrganization.getMachineAlignment()
						: structure.getExplicitMinimumAlignment();
			alignment = Math.max(defaultAlignment, minAlign);
		}

		if (length != 0) {
			length = DataOrganizationImpl.getAlignedOffset(alignment, length);
		}

		return new StructurePackResult(componentCount, length, alignment, componentsChanged);
	}
Perform packing on the structure components.
@return pack result data
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AlignedStructurePacker.java