Re: [HACKERS] pg_malloc() versus malloc(0)

2012-10-01 Thread Dimitri Fontaine
Tom Lane writes: > Namely, that on platforms where malloc(0) returns NULL instead of > a pointer to a zero-size block, pg_malloc thinks it's a failure > and aborts the program. What's the use case for malloc(0) anyway? > 1. Teach pg_malloc not to complain if result == NULL and size == 0. What a

Re: [HACKERS] pg_malloc() versus malloc(0)

2012-10-01 Thread Tom Lane
Peter Geoghegan writes: > On 1 October 2012 15:00, Tom Lane wrote: >> 1. Teach pg_malloc not to complain if result == NULL and size == 0. > +1 to that proposal. >> 2. Before the malloc call, have it replace size == 0 with size = 1. > I don't like that proposal on purely aesthetic grounds. As

Re: [HACKERS] pg_malloc() versus malloc(0)

2012-10-01 Thread Tom Lane
Dimitri Fontaine writes: > Tom Lane writes: >> Namely, that on platforms where malloc(0) returns NULL instead of >> a pointer to a zero-size block, pg_malloc thinks it's a failure >> and aborts the program. > What's the use case for malloc(0) anyway? See getAggregates() for an example. Yeah, w

Re: [HACKERS] pg_malloc() versus malloc(0)

2012-10-01 Thread Peter Geoghegan
On 1 October 2012 15:00, Tom Lane wrote: > 1. Teach pg_malloc not to complain if result == NULL and size == 0. +1 to that proposal. > 2. Before the malloc call, have it replace size == 0 with size = 1. I don't like that proposal on purely aesthetic grounds. -- Peter Geoghegan http://www

[HACKERS] pg_malloc() versus malloc(0)

2012-10-01 Thread Tom Lane
Per http://archives.postgresql.org/pgsql-general/2012-10/msg00013.php we have got a problem with the pg_malloc() interface functions that were recently added to pg_dump and a lot of other frontend code. Namely, that on platforms where malloc(0) returns NULL instead of a pointer to a zero-size block