Re: Combinations of pg_strdup/free in pg_dump code

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Combinations of pg_strdup/free in pg_dump code
Дата
Msg-id 5256.1459174547@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Combinations of pg_strdup/free in pg_dump code  (Michael Paquier <michael.paquier@gmail.com>)
Список pgsql-hackers
Michael Paquier <michael.paquier@gmail.com> writes:
> While reading some code of pg_dump, I noticed that the following
> pattern is heavily present:
>         lanname = pg_strdup(stuff)
>         free(lanname);

> When pg_strdup or any pg-related allocation routines are called, I
> think that we should use pg_free() and not free(). It does not matter
> much in practice because pg_free() calls actually free() and the
> latter per the POSIX spec should do nothing if the input pointer is
> NULL (some version of SunOS that crash on that actually :p), but we
> really had better be consistent in the calls done. Thoughts?

I do not think this is worth troubling over, really.  If there are
places that are relying on free(NULL) to work, it might be worth
ensuring they go through pg_free; but the pattern you show here
is perfectly safe.  We have other things to do besides create
code churn for this.
        regards, tom lane



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Move PinBuffer and UnpinBuffer to atomics
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Draft release notes for next week's releases