Hi,
is it possible that function xfmSettings_getCellName is corrupting stack ?
If I call it (sample below), it returns proper value of cellName (I know what I expect from input Feature definition) but
I have following message in debugger output and modal messagebox in BentleyMap:
Run-Time Check Failure #2 - Stack around the variable 'cellName' was corrupted.
Message is showing on function exit, probably on destroying function local stack.
I've found a nasty workaround, if I declare cellName as global variable I can go on, but it is not a real solution.
Calling another similar functions like xfmSettings_getCellLibrary(smbSettingsData, libraryName); does not produces problem.
Any clues ?
Environment: WindowsXP sp3, MicroStation 8.11.09.366, BentleyMap 8.11.09.110, VisualStudio 2005 Prof.
Richard
int procSubFeatures(MSWChar *rootName) { XfmFeatureP newsub=NULL; long numsubFea=0; XfmFeatureDefP featureDef=NULL; int nSubFeatures, subFeatureIndex; XfmFeatureDefP subFeatureDef=NULL; MSWChar* pName=NULL; status = xfmFeatureDef_create (&featureDef, rootName); if (SUCCESS != status) return status; nSubFeatures = xfmFeatureDef_getNumSubFeatures (featureDef); for (subFeatureIndex=0; subFeatureIndex < nSubFeatures; subFeatureIndex++) { status = xfmFeatureDef_getSubFeatureDef (featureDef, &subFeatureDef, subFeatureIndex); if (SUCCESS != status) { xfmFeatureDef_free (&featureDef); errorPrint(ERRORID_GetDefRootFeature); return ERROR; } status = xfmFeatureDef_getName (subFeatureDef, &pName); if (SUCCESS != status) { xfmFeatureDef_free (&subFeatureDef); xfmFeatureDef_free (&featureDef); return status; } status = xfmFeature_create (&newsub, pName, NULL); if (SUCCESS == status) { status = xfmFeature_addSubFeature (rootFeature, newsub); status = xfmFeature_getSettings (newsub, &smbSettingsData); if (SUCCESS != status) { errorPrint(ERRORID_GetDefSubFeature); xfmFeature_free (&newsub); xfmFeatureDef_free (&subFeatureDef); xfmFeatureDef_free (&featureDef); return status; } } { MSWChar cellName[MAXFILELENGTH]; MSWChar libraryName[MAXFILELENGTH]; DgnFileObjP library = NULL; Dpoint3d cellScale; xfmSettings_getCellName(smbSettingsData, cellName); xfmSettings_getCellLibrary(smbSettingsData, libraryName); xfmSettings_getCellLibraryObj(smbSettingsData, &library); xfmSettings_getCellScaleX(smbSettingsData, &cellScale.x); xfmSettings_getCellScaleY(smbSettingsData, &cellScale.y); xfmSettings_getCellScaleZ(smbSettingsData, &cellScale.z); status = mdlCell_getElmDscr(&smbEdP, NULL, NULL, &cellScale, TRUE, NULL, NULL, 0, FALSE, TRUE, cellName /*L"bubble"*/, library); //mdlElmdscr_show(smbEdP, "--"); } xfmFeature_free (&newsub); _dlmFree(pName); xfmFeatureDef_free (&subFeatureDef); } xfmFeatureDef_free (&featureDef); return SUCCESS;}
Does this still occur if you change the size of the cellName variable and initialize as follows?
MSWChar cellName[MAX_CELLNAME_LENGTH]; memset (cellName, 0, sizeof (cellName));
Regards,
Jeff Bielefeld [Bentley]