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 73F991722F for ; Sun, 22 Feb 2015 12:57:50 +0000 (UTC) Received: (qmail 64112 invoked by uid 500); 22 Feb 2015 12:57:50 -0000 Delivered-To: apmail-corinthia-dev-archive@corinthia.apache.org Received: (qmail 64084 invoked by uid 500); 22 Feb 2015 12:57:50 -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 64072 invoked by uid 99); 22 Feb 2015 12:57:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Feb 2015 12:57:50 +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; Sun, 22 Feb 2015 12:57:27 +0000 Received: (qmail 55532 invoked by uid 99); 22 Feb 2015 12:47:09 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Feb 2015 12:47:09 +0000 Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 09EA01A039A for ; Sun, 22 Feb 2015 12:47:09 +0000 (UTC) Received: by labhz20 with SMTP id hz20so13817494lab.0 for ; Sun, 22 Feb 2015 04:47:07 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.23.233 with SMTP id p9mr5620161laf.123.1424609227554; Sun, 22 Feb 2015 04:47:07 -0800 (PST) Received: by 10.112.230.44 with HTTP; Sun, 22 Feb 2015 04:47:07 -0800 (PST) In-Reply-To: <811A01B4-256D-4BF1-BCC7-55E3294DACAB@apache.org> References: <811A01B4-256D-4BF1-BCC7-55E3294DACAB@apache.org> Date: Sun, 22 Feb 2015 13:47:07 +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=089e0160b864f3c968050facaee2 X-Virus-Checked: Checked by ClamAV on apache.org --089e0160b864f3c968050facaee2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sunday, February 22, 2015, Peter Kelly wrote: > Sounds great - I would just suggest putting the x* function > implementations in Wrapper.c rather than having a separate copy in the > files for each supported platform. Wrapper.c is sort of our generic place > to put things which work the same way on all platforms but still need to > live in the platform module (as is the case for the zip functions which a= re > currently there). +1 to use wrapper.c rgds jan i > > The memory allocation functions are identical for all platforms so I thin= k > it would be better to avoid the code duplication - especially since we=E2= =80=99ll > likely modify these for error handling/cleanup etc. and only want to do s= o > in one place. > > If the diffs are really big, you could perhaps post them as zip files to > cut down on the size. Either that or post them somewhere we can get them; > whatever is most convenient for you. > > =E2=80=94 > Dr Peter M. Kelly > pmkelly@apache.org > > PGP key: http://www.kellypmk.net/pgp-key > (fingerprint 5435 6718 59F0 DD1F BFA0 5E46 2523 BAA1 44AE 2966) > > > On 22 Feb 2015, at 7:13 pm, Gabriela Gibson > wrote: > > > > Hi, > > > > I propose to do the following: > > > > 1) Replace all the calls to *allocs (malloc, calloc, realloc) > > {and also free()} with matching x* functions in DocFormats. > > > > 2) These new x*alloc functions will live in their respective > > platform/src files, and will contain a call to the original > > *alloc function and a simple exit handler. > > > > 3) I will create test cases in platform/tests/ for each of those > > functions. I can either put them in WrapperTests.c or create a > > new, MallocTests.c file for them. > > > > 4) I will start out with free(), just to be certain I get the shape rig= ht > > before I process the rest of the to-do list. > > > > 5) I will ship this as a 'git diff' files. > > > > What do you think? > > > > G > > > > On Wed, Feb 18, 2015 at 9:19 PM, Gabriela Gibson < > gabriela.gibson@gmail.com > > > wrote: > > > >> Hi, > >> > >> Reading through the source, I see that a lot of mallocs() do not have = a > >> > >> [[ > >> if(foo =3D=3D NULL) { > >> perror("Foo: Out of memory.\n"); > >> return _exit(EXIT_FAILURE); > >> } > >> ]] > >> > >> check. > >> > >> I can add those if you like. > >> > >> G > >> -- > >> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/ > >> > > > > > > > > -- > > Visit my Coding Diary: http://gabriela-gibson.blogspot.com/ > > --=20 Sent from My iPad, sorry for any misspellings. --089e0160b864f3c968050facaee2--