You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Senaka Fernando (JIRA)" <ji...@apache.org> on 2007/12/01 15:00:45 UTC
[jira] Closed: (AXIS2C-742) Improper placement of code in
data_handler.c leads to increased time overhead and memory leaks.
[ https://issues.apache.org/jira/browse/AXIS2C-742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Senaka Fernando closed AXIS2C-742.
----------------------------------
Closed Issue
> 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: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org