From 179cae11d7cf4415e1edb906d90105b2921f666d Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 27 Jun 2002 20:44:27 +0000 Subject: * cygheap.cc (cfree_and_set): New function. (cygheap_user::set_name): Use cfree_and_set to reset members. * cygheap.h (cygheap_user): Delete static members. (cygheap_user::puserprof): New member. (cfree_and_set): Declare. * dcrt0.cc (almost_null): Define. * winsup.h (almost_null): Declare. * syscalls.cc (cfree_and_set): Remove unused variable. * uinfo.cc (cygheap_user::homepath_env_buf): Eliminate. (cygheap_user::homedrive_env_buf): Ditto. (cygheap_user::userprofile_env_buf): Ditto. (cygheap_user::ontherange): YA change to try to preserve existing HOMEPATH and HOMEDRIVE. Return almost_null values when variables should not actually exist. (cygheap_user::env_logsrv): Ditto. (cygheap_user::env_domain): Ditto. (cygheap_user::env_userprofile): Ditto. --- winsup/cygwin/cygheap.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/cygheap.cc') diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 561e9330f..2cf7e2068 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -327,6 +327,14 @@ cfree (void *s) MALLOC_CHECK; } +extern "C" void __stdcall +cfree_and_set (char *&s, char *what) +{ + if (s && s != almost_null) + cfree (s); + s = what; +} + extern "C" void *__stdcall ccalloc (cygheap_types x, DWORD n, DWORD size) { @@ -453,15 +461,11 @@ cygheap_user::set_name (const char *new_name) if (!allocated) return; /* Initializing. Don't bother with other stuff. */ - homedrive = NULL; - homepath = NULL; - if (plogsrv) - cfree (plogsrv); - if (pdomain) - cfree (pdomain); - if (winname) - cfree (winname); - plogsrv = pdomain = winname = NULL; + cfree_and_set (homedrive); + cfree_and_set (homepath); + cfree_and_set (plogsrv); + cfree_and_set (pdomain); + cfree_and_set (winname); } BOOL -- cgit v1.2.3