Re: fix a bogus line in dynahash.c
| От | Neil Conway |
|---|---|
| Тема | Re: fix a bogus line in dynahash.c |
| Дата | |
| Msg-id | 4293E7E1.3060001@samurai.com обсуждение исходный текст |
| Ответ на | fix a bogus line in dynahash.c ("Qingqing Zhou" <zhouqq@cs.toronto.edu>) |
| Список | 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
В списке pgsql-patches по дате отправления: