public boolean doRemoveFunction(long key) {
		lock.acquire();

		try {

			FunctionDB function = (FunctionDB) getFunction(key);
			if (function == null) {
				return false;
			}

			thunkAdapter.removeThunkRecord(key);
			function.setInvalid();

			RecordIterator thunks = thunkAdapter.iterateThunkRecords(key);
			if (thunks.hasNext()) {
				// TODO: How should thunks which refer to deleted function be handled?
				//       What about case where use is "re-creating" referenced function?
				// Delete thunks for now...
				DBRecord rec = thunks.next();
				Symbol s = symbolMgr.getSymbol(rec.getKey());
				if (s != null) {
					s.delete();
				}
			}

			Address entryPoint = function.getEntryPoint();
			function.setCallFixup(null); // clear call fixup if any exists
			AddressSetView body = new AddressSet(function.getBody());
			removeVariableRefs(function, body);
			namespaceMgr.removeBody(function);

			int n = function.getParameterCount();
			for (int i = n - 1; i >= 0; i--) {
				function.removeParameter(i);
			}

			// Remove all tag mappings associated with this function
			for (FunctionTag tag : function.getTags()) {
				function.removeTag(tag.getName());
			}

			long functionID = function.getID();
			adapter.removeFunctionRecord(functionID);
			cache.delete(functionID);

			program.setObjChanged(ProgramEvent.FUNCTION_REMOVED, entryPoint, function, body, null);
			return true;
		}
		catch (IOException e) {
			dbError(e);
		}
		finally {
			lock.release();
		}
		return false;
	}
Transform an existing external symbol into an external function.
This method should only be invoked by the Function Manager.
The {@link ExternalLocation#getOriginalImportedName() original imported name} will initially 
be null.

@param extSpaceAddr the external space address to use when creating this external.  Any 
other symbol using this address must first be deleted.  Results are unpredictable if this is 
not done.
@param name the external function name
@param nameSpace the external function namespace
@param externalProgramAddress the external program address (may be null)
@param originalImportName the original imported name if different from name (may be null)
@param source the source of this external.
@return external function
@throws InvalidInputException if the name is invalid
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/function/FunctionManagerDB.java