Skip to main content
12-Amethyst
November 10, 2023
Solved

I wonder how to turn off the parameters of the ProAsmcompMdlMdlnameGet function.

  • November 10, 2023
  • 2 replies
  • 1647 views

You are using the ProAsmcompMdlMdlnameGet function. The document instructs you to release the variable whose name is printed to ProWstringFree(), but if you actually use it, an error will occur and you will be forced to exit.

Can you tell me what to do?

 

 

ProError status;

ProFeattype protype;
ProMdlfileType f_type;
ProFamilyMdlName f_name;

	status = ProFeatureTypeGet(feat, &protype);

	if (protype == PRO_FEAT_COMPONENT)
	{
	 status = ProAsmcompMdlMdlnameGet(feat, &f_type, f_name);
		if (f_type == PRO_MDLFILE_PART)										
		{
			ProWstringFree(f_name);
		}
		
		
	}

	return PRO_TK_NO_ERROR;
}

 

 

 

Best answer by Ben_C

Infact, I have managed to replicate the crash using both &f_name and f_name which indicates a bug in the toolkit function.

 

None of the sample code files provided by PTC that use function ProAsmcompMdlMdlnameGet ( ( TestAsm.c )( TestMechanism.c )( UtilVisit.c )( UgMfgMillSeqCreate.c )) call ProWstringFree, so they may be aware of this issue.

 

If you are able to contact PTC support, you should raise this bug. But, frustrating as this is, it appears the solution here may be not to free the data.

 

 

2 replies

12-Amethyst
November 10, 2023

Pass in

ProWstringFree(&f_name);
Ben_C12-AmethystAnswer
12-Amethyst
November 10, 2023

Infact, I have managed to replicate the crash using both &f_name and f_name which indicates a bug in the toolkit function.

 

None of the sample code files provided by PTC that use function ProAsmcompMdlMdlnameGet ( ( TestAsm.c )( TestMechanism.c )( UtilVisit.c )( UgMfgMillSeqCreate.c )) call ProWstringFree, so they may be aware of this issue.

 

If you are able to contact PTC support, you should raise this bug. But, frustrating as this is, it appears the solution here may be not to free the data.

 

 

17-Peridot
November 10, 2023

This is an error in documentation I believe.

Because, ProFamilyMdlName is an array of fixed size. In this case not needed to free a memory.

typedef wchar_t	ProFamilyMdlName[PRO_FAMILY_MDLNAME_SIZE];