[
https://issues.apache.org/jira/browse/AXIS2C-675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545843
]
Senaka Fernando commented on AXIS2C-675:
----------------------------------------
This is how we free the om element. ({axis2/c installation
home}/axiom/src/om/om_element.c)
647 AXIS2_EXTERN void AXIS2_CALL
648 axiom_element_free(
649 axiom_element_t * om_element,
650 const axutil_env_t * env)
651 {
652 AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
653 if (!om_element)
654 {
655 return;
656 }
657
658 if (om_element->localname)
659 {
660 axutil_string_free(om_element->localname, env);
661 }
662 if (om_element->ns)
663 {
664 /* it is the responsibility of the element where the namespace is
declared to free it */
665 }
666 if (om_element->attributes)
667 {
668 axutil_hash_index_t *hi;
669 void *val = NULL;
670
671 for (hi = axutil_hash_first(om_element->attributes, env); hi;
672 hi = axutil_hash_next(env, hi))
673 {
674 axutil_hash_this(hi, NULL, NULL, &val);
675
676 if (val)
677 {
678 axiom_attribute_free((axiom_attribute_t *) val, env);
679 }
680 }
681 axutil_hash_free(om_element->attributes, env);
682 }
683
684 if (om_element->namespaces)
685 {
686 axutil_hash_index_t *hi;
687 void *val = NULL;
688 for (hi = axutil_hash_first(om_element->namespaces, env); hi;
689 hi = axutil_hash_next(env, hi))
690 {
691 axutil_hash_this(hi, NULL, NULL, &val);
692 if (val)
693 {
694 axiom_namespace_free((axiom_namespace_t *) val, env);
695 }
696 }
697 axutil_hash_free(om_element->namespaces, env);
698 }
699 if (om_element->qname)
700 {
701 axutil_qname_free(om_element->qname, env);
702 }
703 if (om_element->children_iter)
704 {
705 axiom_children_iterator_free(om_element->children_iter, env);
706 }
707 if (om_element->child_ele_iter)
708 {
709 AXIOM_CHILD_ELEMENT_ITERATOR_FREE(om_element->child_ele_iter, env);
710 }
711 if (om_element->children_qname_iter)
712 {
713 axiom_children_qname_iterator_free(om_element->children_qname_iter,
714 env);
715 }
716 if (om_element->text_value)
717 {
718 AXIS2_FREE(env->allocator, om_element->text_value);
719 }
720 AXIS2_FREE(env->allocator, om_element);
721
722 return;
723 }
As in lines 662-665, it is the responsibility of the person who declare the
namespace to free it. Therefore, if you create it in the parent and free it
there, it is lost. Please note that we don't duplicate references or keep
counts, as, it seems not required, according to the present logic.
I don't think that there would be a bug unless we try to do some thing
un-expected.
Regards,
Senaka
> Detach node does not handle namespaces
> --------------------------------------
>
> Key: AXIS2C-675
> URL: https://issues.apache.org/jira/browse/AXIS2C-675
> Project: Axis2-C
> Issue Type: Bug
> Components: xml/om
> Reporter: Jamie Lyon
>
> When detaching a node from a parent, if the current node or any of it's
> children have any namespaces declared in it's parent or above, when the node
> is detached, and the parent freed, any namespace references are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]