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

Re: [PATCHES] backend crashing despite tsearch2 patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: psql-mail(at)freeuk(dot)com, pgsql-general(at)postgresql(dot)org,pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] backend crashing despite tsearch2 patch
Date: 2003-09-18 04:21:40
Message-ID: 8432.1063858900@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-patches
"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> On a matter of style, it's been a while since I've seriously considered cross
> platform C. Is it the done thing to expect:
>  int *i = (int *)calloc(1,sizeof(int));
> to give the condition *i == 0 (assuming the memory allocation worked)?

calloc is defined to zero out the block of memory it returns (as opposed
to malloc which may return a block containing any random junk).

A more serious question is whether any of this code should be using
calloc/malloc as opposed to palloc.  I'd prefer to see it rewritten to
use palloc wherever possible; but that begs the question of what the
required lifespan of the allocations is.

+ #ifndef NULL
+ #define NULL ((void *)0)
+ #endif

It has been roughly twenty years since a C platform existed that didn't
predefine NULL ... and the ones that did not would likely not recognize
the ANSI-C-ism "void *".  So the above is unhelpful by any measure.

			regards, tom lane

In response to

pgsql-patches by date

Next:From: Nigel J. AndrewsDate: 2003-09-18 09:35:11
Subject: Re: [GENERAL] backend crashing despite tsearch2 patch
Previous:From: Nigel J. AndrewsDate: 2003-09-17 23:03:22
Subject: Re: [PATCHES] backend crashing despite tsearch2 patch

pgsql-general by date

Next:From: Tom LaneDate: 2003-09-18 04:27:20
Subject: Re: varchar vs. text
Previous:From: Michael GarrissDate: 2003-09-18 03:59:44
Subject: varchar vs. text

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