[ 
https://issues.apache.org/jira/browse/AXIS2C-742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sanjaya Ratnaweera resolved AXIS2C-742.
---------------------------------------

    Resolution: Fixed

Fixed in current SVN

> Improper placement of code in data_handler.c leads to increased time overhead 
> and memory leaks.
> -----------------------------------------------------------------------------------------------
>
>                 Key: AXIS2C-742
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-742
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: xml/om
>         Environment: Ubuntu 7.10 (Gutsy Gibbon)
>            Reporter: Senaka Fernando
>            Assignee: Sanjaya Ratnaweera
>             Fix For: 1.2.0
>
>         Attachments: diff.txt
>
>
> The code portion
>         struct stat stat_p;
>             if (-1 == stat(data_handler->file_name, &stat_p))
>             {
>                 return AXIS2_FAILURE;
>             }
>             else if (stat_p.st_size == 0)
>             {
>                 *output_stream = NULL;
>                 *output_stream_size = 0;
>                 return AXIS2_SUCCESS;
>             }
> in axis2/c/axiom/src/attachments/data_handler.c (line 175) is repeatedly 
> executed and thus leads to increased time overhead.
> Nevertheless, if the function is to return, resources occupied by byte_stream 
> is not freed, and thus leads to a memory leak.
> I propose to move this portion of code out of the do-while loop.
> Reasons:
>  * Evaluation of stat() just one time is enough as any other error that could 
> occur during reading the file is returned by the fread() and ferror() 
> combination.
>  * Therefore, repeated evaluation of a parameter that is technically not 
> supposed to change, is not worth it.
>  * Even it does change, that particular change may occur just after stat() 
> was evaluated, and thus makes the above argument base-less.
> Thus, it seems to be the best option.

-- 
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]

Reply via email to