axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samisa Abeysinghe" <SAbeysin...@virtusa.com>
Subject RE: Attribute setx()
Date Wed, 04 Aug 2004 02:07:30 GMT
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. 

Mime
View raw message