Details
Description
The code portion
struct stat stat_p;
if (1 == stat(data_handler>file_name, &stat_p))
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.
Attachments
Attachments
Issue Links
- relates to
-
AXIS2C-743 some return paths in axiom_data_handler_read_from() does not call fclose() on the open file stream, in data_handler.c
- Closed