private void setComponentDataType(DataTypeComponentImpl comp, DataType newDt, int index) {

		comp.getDataType().removeParent(this);

		comp.setDataType(newDt); // saves component record
		newDt.addParent(this);

		if (isPackingEnabled()) {
			return;
		}

		int oldLen = comp.getLength();
		int length = getPreferredComponentLength(newDt, oldLen, getAvailableComponentSpace(index));

		if (length < oldLen) {
			comp.setLength(length);
			shiftOffsets(index + 1, oldLen - length, 0); // updates structure record and last modified time
		}
		else if (length > oldLen) {
			int consumed = consumeBytesAfter(index, length - oldLen); // updates component record
			if (consumed > 0) {
				shiftOffsets(index + 1, -consumed, 0); // updates structure record and last modified time
			}
		}
	}
Replaces the internal components of this structure with components of the given structure
including packing and alignment settings.

@param dataType the structure to get the component information from.
@throws IllegalArgumentException if any of the component data types are not allowed to
            replace a component in this composite data type. For example, suppose dt1
            contains dt2. Therefore it is not valid to replace a dt2 component with dt1 since
            this would cause a cyclic dependency.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StructureDataType.java