public int getMaxLength(int stackOffset) {

		int structOffset = computeStructOffsetFromStackOffset(stackOffset, true);

		DataTypeComponent dtc = wrappedStruct.getComponentContaining(structOffset);
		int nextDefinedOffset = wrappedStruct.getLength();
		if (dtc != null) {
			dtc = wrappedStruct.getDefinedComponentAtOrAfterOffset(dtc.getEndOffset() + 1);
			if (dtc != null) {
				nextDefinedOffset = dtc.getOffset();
			}
		}

		int nextStackOffset = computeStackOffsetFromStructOffset(nextDefinedOffset);

		if (stackOffset < 0 && nextStackOffset > 0) {
			// Don't allow the new data type to cross from negative into positive stack space.
			nextStackOffset = 0;
		}
		if ((stackOffset < parameterOffset) && (nextStackOffset >= parameterOffset)) {
			// Don't allow the new data type to cross from local into parameter stack space.
			nextStackOffset = parameterOffset;
		}
		return nextStackOffset - stackOffset;
	}
Get the maximum variable size that will fit at the indicated offset if a replace is done.

@param stackOffset stack offset
@return the maximum size
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java