| From: | Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-hackers(at)postgreSQL(dot)org |
| Subject: | Re: pg_malloc() versus malloc(0) |
| Date: | 2012-10-01 14:30:01 |
| Message-ID: | m2pq52uuxi.fsf@2ndQuadrant.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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?
> 1. Teach pg_malloc not to complain if result == NULL and size == 0.
What about not calling malloc at all in such places? Well I guess what
you want is for the pg_malloc() API to be able to never return NULL…
> 2. Before the malloc call, have it replace size == 0 with size = 1.
As I don't understand the need to malloc 0 byte I would think that's ok
as a way to simplify code…
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2012-10-01 14:36:52 | Re: Extending range of to_tsvector et al |
| Previous Message | Magnus Hagander | 2012-10-01 14:22:14 | Re: Hash id in pg_stat_statements |