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 Raju Koganty <rk...@internetdevices.com> on 2001/02/16 23:27:54 UTC

DOMString transcode function in C++.

I create a DOMString object and get the char * from DOMString::transcode....
The Documetation says the it is the callers responsibility to delete the
allocated  memory.

	XMLPlatformUtils::Initialize();
	DOMString s1("Test");
	char *c1;
	c1=(char *)(s1).transcode();
	cout<<c1<<endl;
	delete [] c1;  //This gives a Seg Fault....

The code below gives a seg fault when I try to delete the char* returned
though it prits its contents correctly.
I'm running it in VC++.

Try this out...and can you please tell me if I am doing something wrong or
there is a problem with the library.

Thanks,
Raju


Re: DOMString transcode function in C++.

Posted by Bob Kline <bk...@rksystems.com>.
On Tue, 20 Feb 2001, Bob Kline wrote:

> On Tue, 20 Feb 2001, Ken Goldman wrote:
> 
> > This question comes up every month.  The usual answer is that you
> > must use the same library as the parser uses.  The threading must
> > match, or the version, or debug vs. release, and so on.
> > 
> > IMHO, the problem is much simpler.  In Windows, I don't think that
> > memory can be allocated in a DLL and then freed in the exe program.
> > 
> > I created a very simple test case, just doing a malloc() in a DLL,
> > returning the pointer to the exe program, and doing a free() in the
> > exe.  I get the same crash as the "delete []" of the transcode
> > pointer.
> 
> Doesn't match my understanding of memory management for Windows
> processes.  Can you supply source code, build scripts, and build
> environment details for your test case?

Hello?  I'm willing to help you figure out why you're getting this
strange behavior, but I can't do it unless you reply with the requested
information.

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com







Re: DOMString transcode function in C++.

Posted by Bob Kline <bk...@rksystems.com>.
On Tue, 20 Feb 2001, Ken Goldman wrote:

> This question comes up every month.  The usual answer is that you
> must use the same library as the parser uses.  The threading must
> match, or the version, or debug vs. release, and so on.
> 
> IMHO, the problem is much simpler.  In Windows, I don't think that
> memory can be allocated in a DLL and then freed in the exe program.
> 
> I created a very simple test case, just doing a malloc() in a DLL,
> returning the pointer to the exe program, and doing a free() in the
> exe.  I get the same crash as the "delete []" of the transcode
> pointer.

Doesn't match my understanding of memory management for Windows
processes.  Can you supply source code, build scripts, and build
environment details for your test case?

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com


Re: DOMString transcode function in C++.

Posted by Ken Goldman <kg...@watson.ibm.com>.
This question comes up every month.  The usual answer is that you must
use the same library as the parser uses.  The threading must match, or
the version, or debug vs. release, and so on.

IMHO, the problem is much simpler.  In Windows, I don't think that
memory can be allocated in a DLL and then freed in the exe program.

I created a very simple test case, just doing a malloc() in a DLL,
returning the pointer to the exe program, and doing a free() in
the exe.  I get the same crash as the "delete []" of the transcode
pointer.

I think the only solution is to change the ...String parser interface
so there is a way to call delete from within the DLL.

> From: "Raju Koganty" <rk...@internetdevices.com>
> Date: Fri, 16 Feb 2001 14:27:54 -0800
> 
> I create a DOMString object and get the char * from DOMString::transcode....
> The Documetation says the it is the callers responsibility to delete the
> allocated  memory.
> 
> 	XMLPlatformUtils::Initialize();
> 	DOMString s1("Test");
> 	char *c1;
> 	c1=(char *)(s1).transcode();
> 	cout<<c1<<endl;
> 	delete [] c1;  //This gives a Seg Fault....
> 
> The code below gives a seg fault when I try to delete the char* returned
> though it prits its contents correctly.
> I'm running it in VC++.
> 
> Try this out...and can you please tell me if I am doing something wrong or
> there is a problem with the library.


-- 
Ken Goldman   kgold@watson.ibm.com   914-784-7646

DTD problem..

Posted by Hyungseok Choi <ch...@mpeg.korea.ac.kr>.
I used xml document appended DTD in the header part of document.

And using xml4com I parsed that in VB program.

Then I saved that document just as it was.

But there was no DTD in the result file.

Is this the normal process..??



____________________________________________________
Hyungseok Choi, M.S Student
School of Electrical Engineering
Korea University
Seoul, South Korea 136-701

Tel) +2-3290-3699 ( Lab )
Email: chs@mpeg.korea.ac.kr
Home : under construction
____________________________________________________