You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Tobias McNulty <tm...@datadesk.com> on 2001/12/28 20:00:03 UTC

DOMString

Is there anything special about the char * returned by 
DOMString::transcode?  I am using DOMString in JNI (which is probably 
part of the problem) -- but I am getting some fairly abnormal 
behavior.  I am wondering if there is anything in particular I have 
to do to dispose of the pointer returned by the above mentioned 
function.

My applet terminates unexpectedly when I call delete myDomString;. 
The error is like so:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0xf586689
Function name=std::bad_exception::what
Library=C:\WINNT\system32\ddjni.dll
Source file = M:\pro 7 builds\MSL\MSL_C\MSL_Common\Src\alloc.c : 807

Deletion of other locally-allocated pointers works fine.

Any ideas?

Thanks,

Toby
-- 
Tobias McNulty
Data Description, Inc.
840 Hanshaw Road, Suite 9
Ithaca, NY 14850
Phone: (607) 257-1000
E-mail: tmcnulty@datadesk.com
Web: www.datadesk.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMString

Posted by Don Mastrovito <dm...@marathontechnologies.com>.
Yes, return=release.

I can't speak for everyone, but when I upgraded the BCB Xerces library, I 
intentionally made it dependent upon the BCB c-rtl (cc3250mt.dll) so that 
the application and the library could use a common memory manager, until 
such time that Xerces implements a solution to the problem.

Another solution would be to link Xerces into your application and 
eliminate the dll altogether.  I personally have not succeeded in doing 
this, but someone recently published how to do this using the MSVC built 
library.  I also recall reading a while back where someone rebuilt Xerces 
and included a routine to release transcoded buffers.  I don't believe 
those changes made it into the "official" sources.

Don

At 02:12 PM 12/28/2001 -0500, you wrote:
>Hi Don,
>
>Thanks for the quick reply.  [In the last paragraph,] by return do you 
>mean release?  If so, I'm curious as to how one is supposed to deal with 
>this Xerces-allocated memory, if normal system functions do not work.
>
>Thanks,
>
>Toby
>
>>Sounds like a heap collision between different memory managers. Transcode 
>>allocates the char* buffer returned to your program.  If your program 
>>utilizes a different memory manager that that of Xerces, you are 
>>effectively releasing memory that you didn't allocate.
>>
>>To the best of my knowledge, Xerces has not implemented a function 
>>through which you can return memory that was allocated by Xerces.
>>
>>HTH,
>>Don
>
>--
>Tobias McNulty
>Data Description, Inc.
>840 Hanshaw Road, Suite 9
>Ithaca, NY 14850
>Phone: (607) 257-1000
>E-mail: tmcnulty@datadesk.com
>Web: www.datadesk.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re[2]: DOMString

Posted by jalal <he...@yahoo.co.uk>.
On Fri, 28 Dec 2001 14:12:25 -0500 Tobias McNulty <tm...@datadesk.com> wrote:

> Hi Don,
> 
> Thanks for the quick reply.  [In the last paragraph,] by return do 
> you mean release?  If so, I'm curious as to how one is supposed to 
> deal with this Xerces-allocated memory, if normal system functions do 
> not work.
> 
> Thanks,
> 
> Toby

Well, I haven't tried this, but...
couldn't you try using the XMLString version of transcode, which allows you
to pass a buffer in:

bool 
transcode (const XMLCh *const toTranscode,
           char *const toFill,
           const unsigned int maxChars)

called like:

DOMString somestring;
//...
char buff[MAX_LEN];
XMLString::transcode( somestring.rawBuffer(), buff, MAX_LEN );

Here the second parameter is a preassigned buffer. The only draw back is
that you need to know the length before hand.

HTH
jalal




_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMString

Posted by Joachim Achtzehnter <jo...@netacquire.com>.
Tobias McNulty wrote:
>
> Thanks for the quick reply.  [In the last paragraph,] by return do
> you mean release?  If so, I'm curious as to how one is supposed to
> deal with this Xerces-allocated memory, if normal system functions do
> not work.

Normal system functions do work, as long as you use the same C runtime
code that Xerces uses. :-)

You didn't mention which platform you're having problems with? Typically,
this happens under Win32, where you get in trouble when different C
runtimes are mixed (msvcrt.dll vs. msvcrtd.dll vs. statically linked CRT,
single-threaded vs. multi-threaded).

Your Java stuff probably uses the release runtime DLL (msvcrt.dll), hence
you should avoid using the debug Xerces DLL. If it still doesn't work,
simply create another DLL that uses the same CRT as Xerces and delete your
strings in there.

Joachim

PS: Yes, it would be nice if Xerces provided an API for freeing objects it
allocated.

-- 
work:     joachima@netacquire.com   (http://www.netacquire.com)
private:  joachim@kraut.ca          (http://www.kraut.ca)


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMString

Posted by Tobias McNulty <tm...@datadesk.com>.
Hi Don,

Thanks for the quick reply.  [In the last paragraph,] by return do 
you mean release?  If so, I'm curious as to how one is supposed to 
deal with this Xerces-allocated memory, if normal system functions do 
not work.

Thanks,

Toby

>Sounds like a heap collision between different memory managers. 
>Transcode allocates the char* buffer returned to your program.  If 
>your program utilizes a different memory manager that that of 
>Xerces, you are effectively releasing memory that you didn't 
>allocate.
>
>To the best of my knowledge, Xerces has not implemented a function 
>through which you can return memory that was allocated by Xerces.
>
>HTH,
>Don

-- 
Tobias McNulty
Data Description, Inc.
840 Hanshaw Road, Suite 9
Ithaca, NY 14850
Phone: (607) 257-1000
E-mail: tmcnulty@datadesk.com
Web: www.datadesk.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMString

Posted by Don Mastrovito <dm...@marathontechnologies.com>.
Sounds like a heap collision between different memory managers.  Transcode 
allocates the char* buffer returned to your program.  If your program 
utilizes a different memory manager that that of Xerces, you are 
effectively releasing memory that you didn't allocate.

To the best of my knowledge, Xerces has not implemented a function through 
which you can return memory that was allocated by Xerces.

HTH,
Don

At 02:00 PM 12/28/2001 -0500, you wrote:
>Is there anything special about the char * returned by 
>DOMString::transcode?  I am using DOMString in JNI (which is probably part 
>of the problem) -- but I am getting some fairly abnormal behavior.  I am 
>wondering if there is anything in particular I have to do to dispose of 
>the pointer returned by the above mentioned function.
>
>My applet terminates unexpectedly when I call delete myDomString;. The 
>error is like so:
>
>An unexpected exception has been detected in native code outside the VM.
>Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0xf586689
>Function name=std::bad_exception::what
>Library=C:\WINNT\system32\ddjni.dll
>Source file = M:\pro 7 builds\MSL\MSL_C\MSL_Common\Src\alloc.c : 807
>
>Deletion of other locally-allocated pointers works fine.
>
>Any ideas?
>
>Thanks,
>
>Toby
>--
>Tobias McNulty
>Data Description, Inc.
>840 Hanshaw Road, Suite 9
>Ithaca, NY 14850
>Phone: (607) 257-1000
>E-mail: tmcnulty@datadesk.com
>Web: www.datadesk.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org