corinthia-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jan i <j...@apache.org>
Subject Re: Checking malloc success and adding perror()
Date Sun, 22 Feb 2015 12:47:07 GMT
On Sunday, February 22, 2015, Peter Kelly <pmkelly@apache.org> 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 are
> currently there).

+1 to use wrapper.c

rgds
jan i

>
> The memory allocation functions are identical for all platforms so I think
> it would be better to avoid the code duplication - especially since we’ll
> likely modify these for error handling/cleanup etc. and only want to do so
> 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.
>
> —
> Dr Peter M. Kelly
> pmkelly@apache.org <javascript:;>
>
> PGP key: http://www.kellypmk.net/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 <gabriela.gibson@gmail.com
> <javascript:;>> 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 right
> > 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 <javascript:;>>
> > 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.
> >>
> >> G
> >> --
> >> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
> >>
> >
> >
> >
> > --
> > Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
>
>

-- 
Sent from My iPad, sorry for any misspellings.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message