@Override
	DataType initializeStructureData(Program program, Structure localStructure) {

		Listing listing = program.getListing();

		Address endAddress;
		try {
			endAddress = getStructureAddress().addNoWrap(structureDataLength - 1);
		}
		catch (AddressOverflowException e1) {
			throw new IllegalArgumentException(
				"Can't create structure because length exceeds address space" +
					structureDataLength);
		}
		ReferenceManager refMgr = program.getReferenceManager();
		List<Reference> refs = findExistingRefs(refMgr, program.getAddressFactory(),
			getStructureAddress(), endAddress);
		listing.clearCodeUnits(getStructureAddress(), endAddress, false);

		Data data = null;
		try {
			listing.createData(getStructureAddress(), localStructure, localStructure.getLength());
			refMgr.removeAllReferencesFrom(getStructureAddress(), endAddress);
			addRefs(program, refMgr, refs);
			data = listing.getDataAt(getStructureAddress());
		}
		catch (CodeUnitInsertionException e) {
			throw new IllegalArgumentException(e.getMessage());
		}

		return data.getDataType();
	}
Creates a new structure by using the provided structure and attaching
it to the program passed in the {@link #applyTo(Program)} method.

@param newStructure The new structure to attach to the program 
       provided in the {@link #applyTo(Program)} method.
@param address the address at which to create the new structure.
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateStructureCmd.java