OpenersNotesSection(Spacer1)Details

The newly created link has an exact copy of the incoming and outgoing data streams of the parent link.

MLDuplicateLink() does not copy user data blocks.

Upon successful completion, MLDuplicateLink() returns a new link object and sets err to MLEOK.

In the event of an error, MLDuplicateLink() returns ((NonWLLink[MLINK, paclet:ref/c/MLINK]))0 and sets err to the appropriate value.

MLDuplicateLink() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* make a copy of a link */

MLINK f(MLINK lp)
{
	MLINK newlink;
	int error;

	newlink = MLDuplicateLink(lp, (const char *)"Duplicate 1", &error);
	if(newlink == (MLINK)0 || error != MLEOK)
		{ /* unable to create a copy of the link */ }

	return newlink;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLSetUserData(), paclet:ref/c/MLSetUserData])  ▪  (NonWLLink[MLUserData(), paclet:ref/c/MLUserData])}})}})