Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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;
}
Solved! Go to Solution.
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.
Pass in
ProWstringFree(&f_name);
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.
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];