diff options
author | Magnus Hagander <magnus@hagander.net> | 2007-10-23 17:58:01 +0000 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2007-10-23 17:58:01 +0000 |
commit | 344d0cae64dbf398559b855806fc7338ec0a2e64 (patch) | |
tree | fa4f3d2cf4c9daf3ee59466aedf44e3f19912066 /src/port/path.c | |
parent | 12f25e70a6feb40b7fba1dcc17deabcffcdfcc3d (diff) | |
download | postgresql-344d0cae64dbf398559b855806fc7338ec0a2e64.tar.gz postgresql-344d0cae64dbf398559b855806fc7338ec0a2e64.zip |
Use snprintf instead of wsprintf, and use getenv("APPDATA") instead of
SHGetFolderPath.
This removes the direct dependency on shell32.dll and user32.dll, which
eats a lot of "desktop heap" for each backend that's started. The
desktop heap is a very limited resource, causing backends to no
longer start once it's been exhausted.
We still have indirect depdendencies on user32.dll through third party
libraries, but those can't easily be removed.
Dave Page
Diffstat (limited to 'src/port/path.c')
-rw-r--r-- | src/port/path.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/port/path.c b/src/port/path.c index 10307d09886..c43843bb464 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/path.c,v 1.71 2007/01/05 22:20:02 momjian Exp $ + * $PostgreSQL: pgsql/src/port/path.c,v 1.72 2007/10/23 17:58:01 mha Exp $ * *------------------------------------------------------------------------- */ @@ -628,10 +628,14 @@ get_home_path(char *ret_path) strlcpy(ret_path, pwd->pw_dir, MAXPGPATH); return true; #else - char tmppath[MAX_PATH]; - - ZeroMemory(tmppath, sizeof(tmppath)); - if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, tmppath) != S_OK) + char *tmppath; + + /* + * 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"); + if (!tmppath) return false; snprintf(ret_path, MAXPGPATH, "%s/postgresql", tmppath); return true; |