new/delete is perfectly cross-platform.  All platforms (that the C api supports 
anyway) these days have C++ compilers with standard STL implementations.  gcc 
is one of them, and works with RTL as well.  As for structure member byte 
alignment, that depends entirely on your compiler.  8 bytes is necessary for MS 
compilers (and I think it's the default), because that's what the C API uses.  
I don't know if it's the same on Linux, but I do know the default gcc byte 
alignment is not the right one, at least on Linux!  For gcc, you have to set 
-malign-xxx (I don't remember exactly...try -malign-double).
 
Even if you get the alignment right, you still have to deal with C runtime 
version, static/dynamic linkage, and debug/release matching.  If you don't have 
the exact same major version of the compiler that BMC used to build the API 
client libraries, and really understand what options to use, don't trust it to 
free memory you allocate!
 
Dan

________________________________

From: Action Request System discussion list(ARSList) on behalf of Beketov Danila
Sent: Tue 5/29/2007 11:16 PM
To: [email protected]
Subject: Re: Problem with function FreeARQualifierStruct


** 

The answer on Appajee's message.

 

I have compiled 'driver' with MSVS.NET2005 and memory allocation problem has 
occurred. But It take place in debug mode (when I press 'F5'). If I compile 
program and execute it by running .exe file or pressing 'CTRL+F5', 'driver' and 
my own program execute without errors. In 'driver' project properties C/C++ -> 
Code Generation -> Basic Runtime Checks has been set to 'default', in my 
project to 'Both (/RTC1, equiv. to /RTCsu)'. My program run without errors (in 
non-debug mode, of cause) when I changed my properties like 'driver'. 

If I comment all except the QualifierStruct's initialization and ARFree, I get 
the same error. It's all the same.

 

I will use my own free function or use both functions in the following way for 
example:

 

   #ifndef FREE_AR

      free(qualifier.u.andor.operandLeft->u.relOp);

      free(qualifier.u.andor.operandRight->u.relOp);

      free(qualifier.u.andor.operandLeft);

      free(qualifier.u.andor.operandRight);

   #else

      FreeARQualifierStruct(&qualifier, FALSE);

   #endif

 

Answer to Dan.

 

I don't want to use new/delete because program will be less cross-platform. And 
I don't know where I can know how to define 'structure byte alignment' from?

__20060125_______________________This posting was submitted with HTML in it___ 

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where the 
Answers Are"

Reply via email to