You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Tankel, Ifat" <If...@icomverse.com> on 2002/06/30 10:51:44 UTC

creating objects (but not using) before calling XMLPlatformUtils: initialize() and XPathEValuator:initialize()

Hi
I have created a class myDom.
This class is to be used by other classes when they need to access/modify
data written in xml format (file or buffer).
This myDom class call XMLPlatformUtils:initialize() and
XPathEValuator:initialize() in its constructor.
This myDom class call XMLPlatformUtils:terminate() and
XPathEValuator:terminate() in its destructor.

But now 
If I follow your advice and I will create 
	DOMParser _domParser;
	XercesDOMSupport _domSupport;
	XercesParserLiaison _parserLiaison;

(instead of 
DOMParser * _domParser;
XercesDOMSupport * _domSupport;
 XercesParserLiaison * _parserLiaison;
and then creating them on the heap)

It means that when I create an instance of myDom class ( on the heap or on
the stuck) the constructor of each of these data member is called before 
call to XMLPlatformUtils:initialize() and XPathEValuator:initialize().

and when this myDom instance is to be destroyed (by delete or by the
compiler) the destructor of each of these data member is called after 
call to XMLPlatformUtils:terminate() and XPathEValuator:terminate()

I have a static counter in myDom class that make sure that these initialize
and terminate are called only once.

Should I call _domParser.reset() _domSupport.reset()  _parserLiaison.reset()
in my destructor before calling XMLPlatformUtils:terminate() and
XPathEValuator:terminate()? 

will I have problem with this myDom class design?

I prefers not to create a static methods in myDom class that the "user" of
myDom class will have to call before and after it use the myDom class.

Ifat




-----Original Message-----
From: David N Bertoni/Cambridge/IBM [mailto:david_n_bertoni@us.ibm.com]
Sent: Thursday, June 27, 2002 6:20 PM
To: 'xalan-c-users@xml.apache.org'
Subject: Re: creating objects on the heap



Yes, you can create them on the heap.  Often, it's more appropriate to
create small objects on the stack, as it reduces worries about memory
leaks, and it's more efficient.

If you want this call to be read/write thread-safe, you'll have to
synchronize access to it yourself.  If you want it to be thread-safe for
reading, you should not have a problem.

Dave



 

                      "Tankel, Ifat"

                      <Ifat_Tankel@ico         To:
"'xalan-c-users@xml.apache.org'" <xa...@xml.apache.org>        
                      mverse.com>              cc:      (bcc: David N
Bertoni/Cambridge/IBM)                                   
                                               Subject: creating objects on
the heap                                           
                      06/27/2002 05:34

                      AM

 

 




Hi
I have created a class myDom.
This class is to be used by other classes when they need to access/modify
data written in xml format (file or buffer).

I whant to create private members which are to be created on the heap
DOMParser * _domParser;
XercesDOMSupport * _domSupport;
 XercesParserLiaison * _parserLiaison;
to use them in myDom methods
I sow that in the samples you usualy create them on the stack


I there any limitation not to create them on the heap?
way?


I will be glad if some one will help me soon
Ifat
ps this class need to be thread safe






<<...OLE_Obj...>>
ifat.tankel@comverse.com
Comverse Divisional Developer
EMEA1 E7-General 3log
03-6454768
053-762891