axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hawkins <HAWKI...@uk.ibm.com>
Subject RE: Attribute setx()
Date Wed, 04 Aug 2004 16:31:38 GMT




Hi Folks,

I don't understand (my lack of c++ knowledge probably!)  why this is OK?
If the client allocates some memory for their attribute using "new" then
they still have a problem in knowing when to delete this object don't they?
And the fact that we have one main Object that copies it (BasicNodes) and
thus they can delete their object immediately and one that doesn't
(Attributes) so they need to know when to delete it is very confusing ?

What is our policy with memory allocation?

I'm not too hot on memory allocation so forgive the dumb questions !


thanks,
John.


John Hawkins




                                                                           
             Roshan                                                        
             Weerasuriya                                                   
             <roshan@opensourc                                          To 
             e.lk>                     Apache AXIS C Developers List       
                                       <axis-c-dev@ws.apache.org>          
             04/08/2004 13:42                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         RE: Attribute setx()                
              "Apache AXIS C                                               
             Developers List"                                              
                                                                           
                                                                           
                                                                           
                                                                           




hi,

Yes, we better change those where ever possiblele, to adhere consistancy
issue. There were changes introduced time to time and certain files were
added at different time intervals, and I guess that is the resaon why
there are diffreneces like this.

Roshan

On Wed, 2004-08-04 at 14:37, Samisa Abeysinghe wrote:
> Oh yes! That solves the problem.
>
> However this brings to light a different problem. Namely 'consistancy'.
> Why are we using two different types in two classes?
> As I can see, in Attribute.cpp, not many STL string operations are used.
Hence cahr* could have
> been used without problem.
>
> Any ideas why we have two different data types in these two classes?
>
> Thanks,
> Samisa...
>
> --- Roshan Weerasuriya <roshan@opensource.lk> wrote:
>
> > hi,
> >
> > I think we don't need to do this, hense all the memeber attributes
> > (m_localname, m_prefix, etc) specified here are of the type AxisString
> > (which is a stl string) and it allocates new memory for the values.
> >
> > Roshan
> >
> > On Wed, 2004-08-04 at 08:07, Samisa Abeysinghe wrote:
> > > Interesting observation!
> > >
> > > I too think Attribute should be doing a deep copy like the BasicNode
> > > does.
> > > This will reduce the coupling between Attribute class and those
classes
> > > that use instances of Attribute.
> > >
> > > BTW: rather than using 'malloc + strcpy' one could use strdup (just
one
> > > call).
> > >
> > > Thanks,
> > > Samisa...
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: John Hawkins [mailto:HAWKINSJ@uk.ibm.com]
> > > Sent: Tuesday, August 03, 2004 10:11 PM
> > > To: axis-c-dev@ws.apache.org
> > > Subject: Attribute setx()
> > >
> > >
> > >
> > >
> > >
> > > Hi Folks,
> > >
> > > the set methods on Attribute all simply use the pointer given to them
-
> > > they do not copy the data e.g.
> > >
> > >
> > > void Attribute::setLocalName(const AxisChar* localname)
> > > {
> > >     m_localname= localname;
> > > }
> > >
> > > void Attribute::setPrefix(const AxisChar* prefix)
> > > {
> > >     m_prefix= prefix;
> > > }
> > >
> > > void Attribute::setUri(const AxisChar* uri)
> > > {
> > >     m_uri= uri;
> > > }
> > >
> > > void Attribute::setValue(const AxisChar* value)
> > > {
> > >     m_value= value;
> > > }
> > >
> > > The set methods on BasicNodes do copy the data. e.g.
> > >
> > > int CharacterElement::setValue(const AxisChar* pachValue)
> > > {
> > >     m_pachValue = (AxisChar*) malloc(strlen(pachValue)+1);
> > >     strcpy(m_pachValue, pachValue);
> > >
> > >     return AXIS_SUCCESS;
> > > }
> > >
> > > Is there any reason why they are different?
> > >
> > > I would assume that we would like the Basicnode style of copying the
> > > data
> > > then the user can be happy in the knowledge that the memory clean up
is
> > > given to them "for free"?
> > >
> > >
> > >
> > >
> > > John Hawkins
> > >
> > >
> > >
> > >
> >
>
--------------------------------------------------------------------------------------------------

> > > This message, including any attachments, contains confidential
information intended for a
> > specific individual and purpose, and is intended for the addressee
only.  Any unauthorized
> > disclosure, use, dissemination, copying, or distribution of this
message or any of its
> > attachments or the information contained in this e-mail, or the taking
of any action based on
> > it, is strictly prohibited.  If you are not the intended recipient,
please notify the sender
> > immediately by return e-mail and delete this message.
> > >
> >
> >
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
>




Mime
View raw message