Hi All
I've been using the 'new' operator to allocate vectors as follows:
DPoint3d *pnts = new DPoint3d[_size_];
........
delete [] pnts;
My question is: is it safer to use dlmSystem_mdlMalloc and dlmSystem_mdlFree to allocate and free memory in MDL applications run offline as a batch pgms?
If the answer is yes then if we're using an external API in our MDL pgm, how is MicroStation managing the memory related to calls to the external dll ?
Thanks,
Nabil
Unknown said:I've been using the 'new' operator to allocate vectors
You're writing C++, so use C++ idioms. In this case, std::vector manages memory so you don't have to. This article about the C++ standard library may help. With modern C++, you don't need to handle memory allocation/deallocation manually. If you need a handle to something, then use a smart pointer.
std::vector
Unknown said:is it safer to use dlmSystem_mdlMalloc and dlmSystem_mdlFree to allocate and free memory in MDL applications
dlmSystem_mdlMalloc
dlmSystem_mdlFree
Use those functions when you are passing data between your app. and MicroStation internals. Usually, MicroStation is allocating memory and you should use dlmSystem_mdlFree to deallocate that memory block passed to you.
For example...
#include <dlmsys.fdf> #include <msfile.fdf> FindFileInfo* fileInfo = NULL; mdlFile_findFiles (&fileInfo, &nFiles, fileSpec, FF_NORMAL); // MicroStation has allocated memory for FindFileInfo and passed ownership to you ... do something with fileInfo // Deallocate memory whose ownership was passed to you dlmSystem_mdlFree (fileInfo);
I can't think of any example where you would allocate memory using dlmSystem_mdlMalloc and then pass ownership of that memory to MicroStation.
Unknown said: is it safer to use ... in MDL applications run offline as a batch pgms?
Please clarify what you mean by 'run offline as a batch pgms'.
Regards, Jon Summers LA Solutions