diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-11 15:57:56 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-11 15:57:56 +0000 |
commit | 6cbfd446475004b0d6e9d0cb98807238ff19c173 (patch) | |
tree | 73e64f669ab3cd3420f63017c43db23e6b929460 /libjava/win32.cc | |
parent | 0fb176ea625b9a8b36b71ca7d8ac0fb1867a5e0d (diff) | |
download | gcc-6cbfd446475004b0d6e9d0cb98807238ff19c173.tar.gz |
2002-04-11 Adam King <aking@dreammechanics.com>
Tom Tromey <tromey@redhat.com>
* include/jvm.h (_Jv_ThrowBadArrayIndex,
_Jv_ThrowNullPointerException): Mark as noreturn.
* win32.cc (_Jv_platform_initProperties): Use _Jv_MallocUnchecked
and _Jv_free. Correctly invoke GetTempPath(). Indentation
fixes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52164 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/win32.cc')
-rw-r--r-- | libjava/win32.cc | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/libjava/win32.cc b/libjava/win32.cc index 67949ee2000..912ca1c7ef3 100644 --- a/libjava/win32.cc +++ b/libjava/win32.cc @@ -76,26 +76,29 @@ _Jv_platform_initProperties (java::util::Properties* newprops) SET ("file.separator", "\\"); SET ("path.separator", ";"); SET ("line.separator", "\r\n"); - SET ("java.io.tmpdir", GetTempPath ()); // Use GetCurrentDirectory to set 'user.dir'. DWORD buflen = MAX_PATH; - char* buffer = (char *) malloc (buflen); + char *buffer = (char *) _Jv_MallocUnchecked (buflen); if (buffer != NULL) { if (GetCurrentDirectory (buflen, buffer)) - SET ("user.dir", buffer); - free (buffer); + SET ("user.dir", buffer); + + if (GetTempPath (buflen, buffer)) + SET ("java.io.tmpdir", buffer); + + _Jv_free (buffer); } // Use GetUserName to set 'user.name'. buflen = 257; // UNLEN + 1 - buffer = (char *) malloc (buflen); + buffer = (char *) _Jv_MallocUnchecked (buflen); if (buffer != NULL) { if (GetUserName (buffer, &buflen)) SET ("user.name", buffer); - free (buffer); + _Jv_free (buffer); } // According to the api documentation for 'GetWindowsDirectory()', the @@ -103,23 +106,23 @@ _Jv_platform_initProperties (java::util::Properties* newprops) // directory or a default directory. On the 3 windows machines I checked // only 1 had it set. If it's not set, JDK1.3.1 seems to set it to // the windows directory, so we'll do the same. - char* userHome = NULL; - if ((userHome = ::getenv( "HOMEPATH" )) == NULL ) + char *userHome = NULL; + if ((userHome = ::getenv ("HOMEPATH")) == NULL ) { // Check HOME since it's what I use. - if ((userHome = ::getenv( "HOME" )) == NULL ) + if ((userHome = ::getenv ("HOME")) == NULL ) { // Not found - use the windows directory like JDK1.3.1 does. - char* winHome = (char *)malloc (MAX_PATH); - if ( winHome != NULL ) + char *winHome = (char *) _Jv_MallocUnchecked (MAX_PATH); + if (winHome != NULL) { if (GetWindowsDirectory (winHome, MAX_PATH)) - SET ("user.home", winHome); - free (winHome); + SET ("user.home", winHome); + _Jv_free (winHome); } } } - if( userHome != NULL ) + if (userHome != NULL) SET ("user.home", userHome); // Get and set some OS info. @@ -128,12 +131,13 @@ _Jv_platform_initProperties (java::util::Properties* newprops) osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx (&osvi)) { - char *buffer = (char *) malloc (30); + char *buffer = (char *) _Jv_MallocUnchecked (30); if (buffer != NULL) { - sprintf (buffer, "%d.%d", (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion); + sprintf (buffer, "%d.%d", (int) osvi.dwMajorVersion, + (int) osvi.dwMinorVersion); SET ("os.version", buffer); - free (buffer); + _Jv_free (buffer); } switch (osvi.dwPlatformId) @@ -169,7 +173,7 @@ _Jv_platform_initProperties (java::util::Properties* newprops) // Set the OS architecture. SYSTEM_INFO si; GetSystemInfo (&si); - switch( si.dwProcessorType ) + switch (si.dwProcessorType) { case PROCESSOR_INTEL_386: SET ("os.arch", "i386"); @@ -191,4 +195,3 @@ _Jv_platform_initProperties (java::util::Properties* newprops) break; } } - |