Re: Win32: Minimising desktop heap usage

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Win32: Minimising desktop heap usage
Дата
Msg-id 12474.1193153403@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Win32: Minimising desktop heap usage  (Dave Page <dpage@postgresql.org>)
Ответы Re: Win32: Minimising desktop heap usage  (Dave Page <dpage@postgresql.org>)
Re: Win32: Minimising desktop heap usage  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-patches
Dave Page <dpage@postgresql.org> writes:
> [ get rid of wsprintf in favor of snprintf ]

+1 for not depending on nonstandard subroutines without need.
But please note the standard locution is snprintf(buf, sizeof(buf), ...
Not sizeof() - 1.

> !     char        *tmppath=0;

Please use NULL not 0 ... actually, since the variable is
unconditionally assigned to just below, I'd say this should just be
"char *tmppath;".  I don't like useless initializations: if the compiler
is not smart enough to discard them then they waste cycles, and they
also increase the risk of bugs-of-omission in future changes.  If
someone were to change things around so that tmppath didn't get assigned
to in one code path, then the compiler would complain about use of an
uninitialized variable --- *unless* you've written a useless
initialization such as the above, in which case the mistake might pass
unnoticed for awhile.  So don't initialize a local variable unless
you're giving it an actually meaningful value.

> !     /*
> !      * Note: We use getenv here because the more modern SHGetSpecialFolderPath()
> !      * will force us to link with shell32.lib which eats valuable desktop heap.
> !      */
> !     tmppath = getenv("APPDATA");

Hmm, is there any functional downside to this?  I suppose
SHGetSpecialFolderPath does some things that getenv does not...

Otherwise it looks good...

            regards, tom lane

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

Предыдущее
От: Dave Page
Дата:
Сообщение: Win32: Minimising desktop heap usage
Следующее
От: Dave Page
Дата:
Сообщение: Re: Win32: Minimising desktop heap usage