Re: fix a bogus line in dynahash.c

From: Neil Conway <neilc(at)samurai(dot)com>
To: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: fix a bogus line in dynahash.c
Date: 2005-05-25 02:50:09
Message-ID: 4293E7E1.3060001@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Qingqing Zhou wrote:
> On a separate matter, can anyone please explain me how this piece of code
> works:
>
> /* no free elements. allocate another chunk of buckets */
> if (!element_alloc(hashp, HASHELEMENT_ALLOC_INCR))
> return NULL; /* out of memory */
>
> element_alloc() in fact uses MemoryContextAlloc() stuff.

Well, element_alloc() uses the hash table's alloc function pointer. In
theory, that could be malloc() or anything else, although I notice this
abstraction is not consistently maintained (e.g. dir_realloc assumes
pfree() is sufficient to free an allocation).

I think it would be a good idea to change dynahash.c to assume that the
hash table's allocation function will elog(ERROR) on out-of-memory, so
its return value will always be non-NULL. This would allow for a bunch
of code to be simplified.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-05-25 02:59:15 Re: fix a bogus line in dynahash.c
Previous Message Neil Conway 2005-05-25 02:49:42 Re: [PATCH] pg_autovacuum commandline password hiding.