Re: Change pfree to accept NULL argument

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Change pfree to accept NULL argument
Дата
Msg-id CAApHDvoDmPhGyHrq9Rp0JyBrrS42jjZtw=d0vDJOJQ=982Py+A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Change pfree to accept NULL argument  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Change pfree to accept NULL argument  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
On Tue, 23 Aug 2022 at 13:17, David Rowley <dgrowleyml@gmail.com> wrote:
> I think making pfree() accept NULL is a bad idea.

One counter argument to that is for cases like list_free_deep().
Right now if I'm not mistaken there's a bug (which I just noticed) in
list_free_private() that would trigger if you have a List of Lists and
one of the inner Lists is NIL.  The code in list_free_private() just
seems to go off and pfree() whatever is stored in the element, which I
think would crash if it found a NIL List.  If pfree() was to handle
NULLs at least that wouldn't have been a crash, but in reality, we
should probably fix that with recursion if we detect the element IsA
List type. If we don't use recursion, then the "free" does not seem
very "deep". (Or maybe it's too late to make it go deeper as it might
break existing code.)

David



В списке pgsql-hackers по дате отправления:

Предыдущее
От: mahendrakar s
Дата:
Сообщение: Re: Stack overflow issue
Следующее
От: Richard Guo
Дата:
Сообщение: Re: Stack overflow issue