Return-Path: Delivered-To: apmail-ws-axis-c-dev-archive@www.apache.org Received: (qmail 30721 invoked from network); 28 Oct 2007 19:34:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Oct 2007 19:34:11 -0000 Received: (qmail 54512 invoked by uid 500); 28 Oct 2007 19:33:59 -0000 Delivered-To: apmail-ws-axis-c-dev-archive@ws.apache.org Received: (qmail 54488 invoked by uid 500); 28 Oct 2007 19:33:59 -0000 Mailing-List: contact axis-c-dev-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: "Apache AXIS C Developers List" Reply-To: "Apache AXIS C Developers List" Delivered-To: mailing list axis-c-dev@ws.apache.org Received: (qmail 54474 invoked by uid 99); 28 Oct 2007 19:33:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Oct 2007 12:33:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Oct 2007 19:34:11 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id BAEAB7141F1 for ; Sun, 28 Oct 2007 12:33:50 -0700 (PDT) Message-ID: <8947020.1193600030762.JavaMail.jira@brutus> Date: Sun, 28 Oct 2007 12:33:50 -0700 (PDT) From: "Senaka Fernando (JIRA)" To: axis-c-dev@ws.apache.org Subject: [jira] Created: (AXIS2C-742) Improper placement of code in data_handler.c leads to increased time overhead and memory leaks. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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 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