private static void adjustStructureSize(Structure struct, int preferredSize) {

		DataTypeComponent dtc = struct.getComponentContaining(preferredSize);
		if (dtc == null) {
			struct.growStructure(preferredSize - struct.getLength());
			return;
		}

		int startOrdinal = dtc.getOrdinal();
		if (dtc.getOffset() != preferredSize) {
			++startOrdinal;
		}

		for (int i = struct.getNumComponents() - 1; i >= startOrdinal; i--) {
			DataTypeComponent comp = struct.getComponent(i);
			if (comp.getOffset() < preferredSize || comp.getDataType() != DataType.DEFAULT) {
				break;
			}
			struct.delete(i);
		}
	}
Bitfield insertions can cause excess growth of structure which must be trimmed.
@param struct structure to be trimmed
@param preferredSize preferred structure size
Ghidra/Features/Base/src/main/java/ghidra/app/merge/datatypes/DataTypeMergeManager.java