From: George R. <gr...@us...> - 2003-02-06 02:35:01
|
The purpose of U_OVERRIDE_CXX_ALLOCATION was to make it so that people could have either a static or a shared C runtime library. Obviously STL doesn't like the way we did this. Manually changing the C run-time library is one way to fix this problem, and it looks like you did that correctly. Unfortunately this isn't an ideal solution. I've done a little research, and I think adding these two lines to UObject.h may fix your problem. I haven't fully tested these functions, but at least it compiles and runs with your example. inline void *__cdecl operator new(size_t, void *_P) {return (_P); } inline void __cdecl operator delete(void *, void *) {return; } Could you please try that with your copy of ICU, and see if it works? If it does work, I'll put it into the next release of ICU. George Rhoten IBM Globalization Center of Competency/ICU San Jose, CA, USA "Mathieu Tremblay" <mtr...@go...> Sent by: icu...@os... 02/05/2003 01:48 PM To: <icu...@os...> cc: Subject: ICU C++ Win32 DLL Memory management issue Hi there, As you probably have guessed, I have a problem with ICU4C: I have a DLL which represents a XML Database. This dll exports an object X. This object X has a function that receives in argument a vector<UnicodeString>*, which is created in my main application (not in the dll). ======================================================================== == Ex: someDllObject; //my instance of the object exported by the DLL vector<UnicodeString> uvec; uvec.push_back(someunicodestring); someDllObject->Function(&uvec); and In Function (which is executed in the DLL) i try to add a UnicodeString to the vector. ======================================================================== === (To be able to create a vector<UnicodeString> without getting the error : new function does not take 2 parameters I had to edit the following line from pwin32.h : #define U_OVERRIDE_CXX_ALLOCATION 0 (line 64) ). That DLL (in Function() ) tries to add an element to the vector<UnicodeString>*. The problem is that when the added UnicodeString is deleted, Visual Studio raises an exception. I had a similar problem with a vector<string> but when I compile in "Debug multithreaded DLL" instead of just "Debug multithreaded" the problem is fixed since the DLL and the Application share the same memory this way. It just looks like the memory between the DLL and the vector<UnicodeString> isn't shared. I guess that is why we cant create vector<UnicodeString> in the beginning and I had to modify pwin32.h ?!? Is there something I do wrong, should I restore pwin32.h as it was in the beginning ? But then, how do we create a vector of UnicodeString ? Any help would be appreciated !!! ;) Thanks Mathieu Tremblay _______________________________________________ icu...@os... - icu4c-support mailing list To Un/Subscribe: http://oss.software.ibm.com/developerworks/oss/mailman/listinfo/icu4c-support |