Skip site navigation (1) Skip section navigation (2)

Re: pg_malloc() versus malloc(0)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: pg_malloc() versus malloc(0)
Date: 2012-10-01 14:45:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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, we could add a special-case
code path for no aggregates, but it would be annoying and error-prone.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2012-10-01 14:49:29
Subject: Re: CTE optimization fence on the todo list?
Previous:From: Bruce MomjianDate: 2012-10-01 14:43:00
Subject: Re: WIP checksums patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group