axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nshif...@worldbank.org
Subject Crash when using axiom_element_get_text()
Date Fri, 02 Nov 2012 16:35:36 GMT
<html><body>
<p><font size="2" face="sans-serif">Hi Nandika, </font><br>
<br>
<font size="2" face="sans-serif">I have seen some complains about memory management
of </font><font size="2" face="sans-serif"><b>axiom_element_get_text()</b></font><font
size="2" face="sans-serif">&nbsp;on the net. </font><br>
<font size="2" face="sans-serif">My issue is that my C/UNIX application crashes when
I use this function.</font><br>
<br>
<font size="2" face="sans-serif">My code is:</font><br>
<br>
<font size="2" face="sans-serif">axis2_char_t * axis_str;</font><br>
<font size="2" face="sans-serif">while( node3 = axiom_children_iterator_next( response_it,
env ) )</font><br>
<font size="2" face="sans-serif">{</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; ele3 = (axiom_element_t *) axiom_node_get_data_element(
node3, env );</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; axis_str = axiom_element_get_text(
ele3, env, node3 );</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; if( axis_str &amp;&amp;
strlen(axis_str) )</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
AXIS2_FREE( env-&gt;allocator, axis_str );</font><br>
<font size="2" face="sans-serif">}</font><br>
<br>
<font size="2" face="sans-serif">Later on, when I exit the application, I call these
2 functions:</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp;axis2_svc_client_free(svc_client,
env);</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp;axutil_env_free( env );</font><br>
<br>
<font size="2" face="sans-serif">When I replaced the line</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; axis_str = axiom_element_get_text(
ele3, env, node3 );</font><br>
<font size="2" face="sans-serif">with the following:</font><br>
<font size="2" face="sans-serif">&nbsp; &nbsp; axis_str = axiom_node_to_string(
node3, env );</font><br>
<font size="2" face="sans-serif">in the above code, the application doesn't crash anymore.</font><br>
<br>
<font size="2" face="sans-serif">My questions are:</font><br>
<font size="2" face="sans-serif">- how am I supposed to handle the pointer to </font><font
size="2" face="sans-serif"><b>axis2_char_t </b></font><font size="2"
face="sans-serif">returned by </font><font size="2" face="sans-serif"><b>axiom_element_get_text</b></font><font
size="2" face="sans-serif"><b>()</b></font><font size="2" face="sans-serif">&nbsp;and
</font><font size="2" face="sans-serif"><b>axiom_node_to_string</b></font><font
size="2" face="sans-serif"><b>()</b></font><font size="2" face="sans-serif">?
</font><br>
<font size="2" face="sans-serif">- should I call </font><font size="2" face="sans-serif">AXIS2_FREE</font><font
size="2" face="sans-serif"><b>&nbsp;</b></font><font size="2"
face="sans-serif">for the </font><font size="2" face="sans-serif"><b>axis2_char_t
</b></font><font size="2" face="sans-serif">*</font><font size="2"
face="sans-serif">, after I am done using it?</font><br>
<font size="2" face="sans-serif">- can I safely reuse the pointer to </font><font
size="2" face="sans-serif"><b>axis2_char_t </b></font><font size="2"
face="sans-serif">in the calls to </font><font size="2" face="sans-serif"><b>axiom_element_get_text()</b></font><font
size="2" face="sans-serif">&nbsp;or </font><font size="2" face="sans-serif"><b>axiom_node_to_string()</b></font><font
size="2" face="sans-serif">, such as in the above while loop?</font><br>
<font size="2" face="sans-serif">- why using </font><font size="2" face="sans-serif"><b>axiom_node_to_string()</b></font><font
size="2" face="sans-serif">&nbsp;fixes the crash problem? &nbsp;</font><br>
<br>
<font size="2" face="sans-serif">Thanks,</font><br>
<font size="2" face="sans-serif">Nadine</font></body></html>


---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Mime
View raw message