axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samisa Abeysinghe <sam...@wso2.com>
Subject Re: memory #2 in generated code
Date Tue, 06 Jul 2010 23:24:39 GMT
This too need to be fixed in the code generation template.

Samisa...

On Sun, Jun 27, 2010 at 11:31 PM, Steve Leland <steve@pouchapond.com> wrote:

> Hi,
>
> I am running on Windows Server 2008 R2, and using a build I made yesterday
> (svn 957643) I generated code from our wsdl and ran it - it has a leak that
> was also present in the 1.6.0 release.
>
> Given this in the wsdl file:
>
>     <s:complexType name="ResponseMessageType">
>       <s:sequence>
>         <s:element minOccurs="0" maxOccurs="1" name="Attendee"
> type="tns:EmailAddress" />
>         <s:element minOccurs="0" maxOccurs="1" name="MessageText"
> type="s:string" />
>         <s:element minOccurs="0" maxOccurs="1" name="ResponseCode"
> type="tns:ResponseCodeType" />
>         <s:element minOccurs="0" maxOccurs="1" name="DescriptiveLinkKey"
> type="s:int" />
>         <s:element minOccurs="0" maxOccurs="1" name="MessageXml">
>           <s:complexType>
>             <s:sequence>
>               <s:any minOccurs="0" maxOccurs="unbounded" />
>             </s:sequence>
>           </s:complexType>
>         </s:element>
>       </s:sequence>
>       <s:attribute name="ResponseClass" type="tns:ResponseClassType"
> use="required" />
>     </s:complexType>
>
> ...
>
>     <s:simpleType name="ResponseClassType">
>       <s:restriction base="s:string">
>         <s:enumeration value="Success" />
>         <s:enumeration value="Warning" />
>         <s:enumeration value="Error" />
>       </s:restriction>
>     </s:simpleType>
>
>
>
> the following code is generated twice - after the comments say it is
> building MessageText, the value it is comparing to 'key' is "nil|
> http://www.w3.org/2001/XMLSchema-instance" and  after the comments say it
> is building MessageXml, the value it is comparing to 'key' is
> "ResponseClass", like this:
>
>                 attrib_text = NULL;
>                 if(attribute_hash)
>                 {
>                      axutil_hash_index_t *hi;
>                      void *val;
>                      const void *key;
>
>                      for (hi = axutil_hash_first(attribute_hash, env); hi;
> hi = axutil_hash_next(env, hi))
>                      {
>                          axutil_hash_this(hi, &key, NULL, &val);
>
>
>                              if(!strcmp((axis2_char_t*)key,
> "ResponseClass"))
>
>                              {
>                                  parent_attri = (axiom_attribute_t*)val;
>                                  break;
>                              }
>                      }
>                 }
>
>
> The leak can be fixed by making the body of the for loop look like this:
>
>                 attrib_text = NULL;
>                 if(attribute_hash)
>                 {
>                      axutil_hash_index_t *hi;
>                      void *val;
>                      const void *key;
>
>                      for (hi = axutil_hash_first(attribute_hash, env); hi;
> hi = axutil_hash_next(env, hi))
>                      {
>                          axutil_hash_this(hi, &key, NULL, &val);
>
>
>                              if(!strcmp((axis2_char_t*)key,
> "ResponseClass"))
>
>                              {
>                                  parent_attri = (axiom_attribute_t*)val;
>                                  AXIS2_FREE(env->allocator, hi); // hi
> normally deleted when axutil_hash_next comes to end
>                                  break;
>                              }
>
>                              if (val)
>                             {
>                                  AXIS2_FREE(env->allocator, val);
>                             }
>                      }
>                 }
>
> Regards,
>
> Steve
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-dev-help@axis.apache.org
>
> Samisa Abeysinghe
VP Engineering
WSO2 Inc.
http://wso2.com
http://wso2.org

Mime
View raw message