Return-Path: X-Original-To: apmail-corinthia-dev-archive@minotaur.apache.org Delivered-To: apmail-corinthia-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 264D010DF4 for ; Wed, 18 Feb 2015 22:01:02 +0000 (UTC) Received: (qmail 8544 invoked by uid 500); 18 Feb 2015 22:00:46 -0000 Delivered-To: apmail-corinthia-dev-archive@corinthia.apache.org Received: (qmail 8514 invoked by uid 500); 18 Feb 2015 22:00:46 -0000 Mailing-List: contact dev-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list dev@corinthia.incubator.apache.org Received: (qmail 8503 invoked by uid 99); 18 Feb 2015 22:00:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2015 22:00:46 +0000 X-ASF-Spam-Status: No, hits=-1997.8 required=5.0 tests=ALL_TRUSTED,HTML_MESSAGE,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 18 Feb 2015 22:00:24 +0000 Received: (qmail 8142 invoked by uid 99); 18 Feb 2015 22:00:21 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Feb 2015 22:00:21 +0000 Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 1AD241A02BD for ; Wed, 18 Feb 2015 22:00:21 +0000 (UTC) Received: by labgd6 with SMTP id gd6so4124053lab.7 for ; Wed, 18 Feb 2015 14:00:19 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.198.203 with SMTP id je11mr1402200lac.48.1424296819808; Wed, 18 Feb 2015 14:00:19 -0800 (PST) Received: by 10.112.230.44 with HTTP; Wed, 18 Feb 2015 14:00:19 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 23:00:19 +0100 Message-ID: Subject: Re: Checking malloc success and adding perror() From: jan i To: "dev@corinthia.incubator.apache.org" Content-Type: multipart/alternative; boundary=001a11348870ffe407050f63f182 X-Virus-Checked: Checked by ClamAV on apache.org --001a11348870ffe407050f63f182 Content-Type: text/plain; charset=UTF-8 Hi First thanks for your ideas, they are very welcome. On 18 February 2015 at 22:19, Gabriela Gibson wrote: > Hi, > > Reading through the source, I see that a lot of mallocs() do not have a > > [[ > if(foo == NULL) { > perror("Foo: Out of memory.\n"); > return _exit(EXIT_FAILURE); > } > ]] > > check. > > I can add those if you like. > It get a big +1 from me. BUT if you do it generally I would prefer we make a central function in e.g. platform void DFextBailout() { perror(...) exit(EXIT_FAILURE) } That way we only need to change in one place if we e.g. one day want a special logging. I would NOT make a assert() like macro that includes the condition. Please wait for Peter to comment, he might remember why there was no tests in the first place. rgds jan i. > G > -- > Visit my Coding Diary: http://gabriela-gibson.blogspot.com/ > --001a11348870ffe407050f63f182--