axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Senaka Fernando (JIRA)" <j...@apache.org>
Subject [jira] Updated: (AXIS2C-742) Improper placement of code in data_handler.c leads to increased time overhead and memory leaks.
Date Sun, 28 Oct 2007 19:52:50 GMT

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

Senaka Fernando updated AXIS2C-742:
-----------------------------------

    Attachment: diff.txt

Refer diff.txt for patch proposed for this issue, as well as issue AXIS2C-743.

Regards,
Senaka

> 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
>         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: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Mime
View raw message