public Data createCodeUnit(Address addr, DataType dataType, int length)
			throws CodeUnitInsertionException {

		lock.acquire();

		DataDB data = null;
		try {

			if (dataType instanceof BitFieldDataType) {
				throw new CodeUnitInsertionException("Bitfields not supported for Data");
			}

			DataType originalDataType = dataType;
			if (dataType instanceof FactoryDataType) {
				MemBuffer memBuffer = new MemoryBufferImpl(program.getMemory(), addr);
				dataType = ((FactoryDataType) dataType).getDataType(memBuffer);
				length = -1; // ignore user-specified length for factory use
			}

			if (dataType == null) {
				throw new CodeUnitInsertionException("Failed to resolve data type");
			}

			dataType = dataType.clone(dataManager); // make sure sizes are correct

			boolean isFunctionDef = (dataType instanceof FunctionDefinition);
			if (dataType instanceof TypeDef) {
				isFunctionDef =
					(((TypeDef) dataType).getBaseDataType() instanceof FunctionDefinition);
			}
			if (isFunctionDef) {
				dataType = new PointerDataType(dataType, dataType.getDataTypeManager());
				length = dataType.getLength();
			}
			else if (dataType instanceof Dynamic) {
				Dynamic dynamicDataType = (Dynamic) dataType;
				MemBuffer memBuffer = new MemoryBufferImpl(program.getMemory(), addr);
				length = dynamicDataType.getLength(memBuffer, length);
			}
			else {
				length = dataType.getLength();
			}

			if (length < 0) {
				throw new CodeUnitInsertionException(
					"Failed to resolve data length for " + originalDataType.getName());
			}
			if (length == 0) {
				throw new CodeUnitInsertionException(
					"Zero-length data not allowed " + originalDataType.getName());
			}

			Address endAddr = addr.addNoWrap(length - 1);

			checkValidAddressRange(addr, endAddr);

			if (dataType == DataType.DEFAULT) {
				return getUndefinedDataDB(addr, addrMap.getKey(addr, false));
			}

			DBRecord record = dataAdapter.createData(addr, dataManager.getResolvedID(dataType));

			DataType baseDt = dataType;
			if (baseDt instanceof TypeDef) {
				baseDt = ((TypeDef) baseDt).getBaseDataType();
			}
			if (dataType.getLength() < 1) {
				lengthMgr.add(addr, length);
			}
			cache.delete(addrMap.getKeyRanges(addr, endAddr, false));

			data = getDataDB(record);
			baseDt = data.getBaseDataType();

			if (dataType instanceof Composite || dataType instanceof Array ||
				dataType instanceof Dynamic) {
				compositeMgr.add(addr);
				program.setChanged(ProgramEvent.COMPOSITE_ADDED, addr, endAddr, null, null);
			}

			// fire event
			program.setChanged(ProgramEvent.CODE_ADDED, addr, endAddr, null, data);

			addDataReferences(data, new ArrayList<Address>());

		}
		catch (AddressOverflowException e) {
			throw new CodeUnitInsertionException("Code unit would extend beyond Address space");
		}
		catch (IOException e) {
			program.dbError(e);
		}
		finally {
			lock.release();
		}
		return data;
	}
Creates a data at the specified address.

@param addr Starting address of code unit
@param dataType data prototype for the code unit
@param length the data length
@return the data
@exception CodeUnitInsertionException if the code unit overlaps with an existing code unit
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/code/CodeManager.java