On 18/11/2013 at 13:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R9 - R15
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
OK, in my attempt to keep my code backward compatible I've created lots of wrapper functions with preprocessor directives that check the API_VERSION and compile accordingly. This has been working beautifully in that I only code once and compile for all versions.
But with the memory allocation changes in R15, I've run into a small snag.
Here is my wrapper code for GeAlloc()/GeFree() and NewMemClear()/DeleteMem() :
template<typename T>
T* CDAlloc(LONG s)
{
#if API_VERSION < 15000
LONG size = sizeof(T) * s;
return (T* )GeAlloc(size);
#else
return (T* )NewMemClear(T,s);
#endif
}
template<typename T>
void CDFree(T* x)
{
#if API_VERSION < 15000
GeFree(x);
#else
DeleteMem(x);
#endif
}
... which seems to work except for an intermittent crash upon calling CDFree().
Is there something wrong with the above code?
Adios,
Cactus Dan