Hugo is right here - there are many things you have to very careful of, 
including structure byte alignment, relaese/debug, new/delete vs malloc/free, 
and version of msft c runtime.  Those can all lead to nasty runtime errors.  
The most likely ones here are DLL vs static linkage, release/debug, or C 
runtime version.
 
However, most of that is a moot point.  A better mandate is "never use a 
library's free functions to free memory the library didn't allocate itself!"  
You really have no way of confidently knowing that will work.  Never call 
FreeARQualifierStruct to free an ARQualifierStruct that you allocated yourself. 
 Just free it yourself instead!  This guarantees you won't have any issues.  
(You will, however, have to deal with structure byte alignment if you pass it 
into the API.  An argument for using Java instead.).
 
The above approach is exactly the approach the RTL library uses.  If possible, 
I'd recommend you just use that library and be done with it.  See 
http://rtl.sourceforge.net/doc.  In general, it frees memory allocated by the 
API as quickly as possible, and manages everything in object-oriented classes 
and standard collections.  The classes manage their own memory usage, but can 
cast themselves to C structures usable by the API.  It solves the above problem 
for you, and you have basically zero memory management overhead as it provides 
encapsulation, memory management, collections, etc.  It most likely has the 
functionality you need, and is far simpler.  Your code will be ~80% smaller too.
 
Dan
 

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

Reply via email to