new module 'calloc-posix' (was: Re: getline() behaviour change)

2007-09-02 Thread Bruno Haible
Eric Blake wrote: > > I would somewhat like this idea - it is much nicer assuming that malloc > > reliably sets errno to ENOMEM on failure than having to patch all callers > > of malloc to do the same. Jim Meyering confirmed: > Yes. This is a fundamental goal of gnulib: > If there is some portabi

Re: getline() behaviour change

2007-08-24 Thread Jim Meyering
Eric Blake <[EMAIL PROTECTED]> wrote: > According to Ben Pfaff on 8/22/2007 5:19 PM: >> Bruno Haible <[EMAIL PROTECTED]> writes: >> >>> Jim Meyering wrote: A *lot* of code expects malloc and realloc to set errno when they fail. >>> Such code is not portable to plain ISO C 99 systems. >> >> We

Re: getline() behaviour change

2007-08-22 Thread Jim Meyering
Ben Pfaff <[EMAIL PROTECTED]> wrote: > Bruno Haible <[EMAIL PROTECTED]> writes: > >> Jim Meyering wrote: >>> A *lot* of code expects malloc and realloc to set errno when they fail. >> >> Such code is not portable to plain ISO C 99 systems. > > We could extend gnulib's existing malloc/realloc wrapp

do not set errno after failing malloc [Re: getline() behaviour change

2007-08-22 Thread Jim Meyering
Bruno Haible <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: >> Are you advocating support for non-POSIX malloc/realloc? > > Sure. gnulib supports - to a large extent - mingw. It uses a malloc > implementation from msvcrt.dll. This malloc does not set errno. You're dumbing down gnulib to accommod

Re: getline() behaviour change

2007-08-22 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Ben Pfaff on 8/22/2007 5:19 PM: > Bruno Haible <[EMAIL PROTECTED]> writes: > >> Jim Meyering wrote: >>> A *lot* of code expects malloc and realloc to set errno when they fail. >> Such code is not portable to plain ISO C 99 systems. > > W

Re: getline() behaviour change

2007-08-22 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 8/22/2007 3:25 PM: >> >> - if (*lineptr == NULL || *n == 0) >> + if (*n == 0) > > This is a behaviour change: Previously when *lineptr == NULL, *n did not > need to be initialized. Now it needs to be initialized to 0.

Re: getline() behaviour change

2007-08-22 Thread Ben Pfaff
Bruno Haible <[EMAIL PROTECTED]> writes: > Jim Meyering wrote: >> A *lot* of code expects malloc and realloc to set errno when they fail. > > Such code is not portable to plain ISO C 99 systems. We could extend gnulib's existing malloc/realloc wrappers to ensure that malloc/realloc set errno when

Re: getline() behaviour change

2007-08-22 Thread Bruno Haible
Jim Meyering wrote: > Are you advocating support for non-POSIX malloc/realloc? Sure. gnulib supports - to a large extent - mingw. It uses a malloc implementation from msvcrt.dll. This malloc does not set errno. > A *lot* of code expects malloc and realloc to set errno when they fail. Such code i

Re: getline() behaviour change

2007-08-22 Thread Jim Meyering
Hi Bruno, Thanks for all the reviews. I haven't had time to look at the rest, but the following stood out: Bruno Haible <[EMAIL PROTECTED]> wrote: > The POSIX spec implies that errno should be set when getdelim fails. Therefore > errno needs to be set not only here, with EOVERFLOW. In lines 77 an

Re: getline() behaviour change

2007-08-22 Thread Bruno Haible
Hi Eric, > The patch includes a couple of bug fixes in getdelim.c: > > It is valid on entrance for *lineptr to be non-NULL but *n to be 0 (ie. > via malloc(0)), but your implementation was leaking that memory. Also, > your implementation failed to set errno to EOVERFLOW when it detects that > it