You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by John Hawkins <HA...@uk.ibm.com> on 2004/08/03 18:10:51 UTC

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