Imported Upstream version 2.67.2
[platform/upstream/glib.git] / glib / gutils.c
index 572c06c..d3e4e19 100644 (file)
@@ -982,7 +982,6 @@ g_get_host_name (void)
       gchar *utmp;
 
 #ifndef G_OS_WIN32
-      glong max;
       gsize size;
       /* The number 256 * 256 is taken from the value of _POSIX_HOST_NAME_MAX,
        * which is 255. Since we use _POSIX_HOST_NAME_MAX + 1 (= 256) in the
@@ -994,15 +993,19 @@ g_get_host_name (void)
       gchar *tmp;
 
 #ifdef _SC_HOST_NAME_MAX
-      max = sysconf (_SC_HOST_NAME_MAX);
-      if (max > 0 && max <= G_MAXSIZE - 1)
-        size = (gsize) max + 1;
-      else
+      {
+        glong max;
+
+        max = sysconf (_SC_HOST_NAME_MAX);
+        if (max > 0 && (gsize) max <= G_MAXSIZE - 1)
+          size = (gsize) max + 1;
+        else
 #ifdef HOST_NAME_MAX
-        size = HOST_NAME_MAX + 1;
+          size = HOST_NAME_MAX + 1;
 #else
-        size = _POSIX_HOST_NAME_MAX + 1;
+          size = _POSIX_HOST_NAME_MAX + 1;
 #endif /* HOST_NAME_MAX */
+      }
 #else
       /* Fallback to some reasonable value */
       size = 256;
@@ -1961,7 +1964,7 @@ load_user_special_dirs (void)
 
   wchar_t *wcp;
 
-  p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (GetModuleHandle ("shell32.dll"),
+  p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
                                                                    "SHGetKnownFolderPath");
 
   g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
@@ -2292,26 +2295,14 @@ get_module_for_address (gconstpointer address)
 {
   /* Holds the g_utils_global lock */
 
-  static gboolean beenhere = FALSE;
-  typedef BOOL (WINAPI *t_GetModuleHandleExA) (DWORD, LPCTSTR, HMODULE *);
-  static t_GetModuleHandleExA p_GetModuleHandleExA = NULL;
   HMODULE hmodule = NULL;
 
   if (!address)
     return NULL;
 
-  if (!beenhere)
-    {
-      p_GetModuleHandleExA =
-       (t_GetModuleHandleExA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
-                                              "GetModuleHandleExA");
-      beenhere = TRUE;
-    }
-
-  if (p_GetModuleHandleExA == NULL ||
-      !(*p_GetModuleHandleExA) (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
-                               GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
-                               address, &hmodule))
+  if (!GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
+                          GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+                          address, &hmodule))
     {
       MEMORY_BASIC_INFORMATION mbi;
       VirtualQuery (address, &mbi, sizeof (mbi));
@@ -3102,7 +3093,7 @@ g_abort (void)
 {
   /* One call to break the debugger */
   DebugBreak ();
-  /* One call in case CRT does get saner about abort() behaviour */
+  /* One call in case CRT changes its abort() behaviour */
   abort ();
   /* And one call to bind them all and terminate the program for sure */
   ExitProcess (127);