Do TLS using pthreads if __thread keyword not supported.
[mono.git] / mono / metadata / locales.c
index 0e685c3c5ea5236761a24c5d50cba2ce63d4fb7c..9d977d1e85e2b00979fc9584366cae42c9a18527 100644 (file)
@@ -5,7 +5,8 @@
  *     Dick Porter (dick@ximian.com)
  *     Mohammad DAMT (mdamt@cdl2000.com)
  *
- * (C) 2003 Ximian, Inc.
+ * Copyright 2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  * (C) 2003 PT Cakram Datalingga Duaribu  http://www.cdl2000.com
  */
 
@@ -102,7 +103,7 @@ create_group_sizes_array (const gint *gs, gint ml)
                len++;
        }
        
-       ret = mono_array_new (mono_domain_get (),
+       ret = mono_array_new_cached (mono_domain_get (),
                        mono_get_int32_class (), len);
 
        for(i = 0; i < len; i++)
@@ -129,7 +130,7 @@ create_names_array_idx (const guint16 *names, int ml)
                len++;
        }
 
-       ret = mono_array_new (mono_domain_get (), mono_get_string_class (), len);
+       ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), len);
 
        for(i = 0; i < len; i++)
                mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
@@ -387,7 +388,7 @@ get_current_locale_name (void)
 
        if ((p = strchr (locale, '.')) != NULL) {
                /* assume new locale can't be larger than old one? */
-               corrected = malloc (strlen (locale));
+               corrected = g_malloc (strlen (locale));
                strncpy (corrected, locale, p - locale);
                corrected [p - locale] = 0;
 
@@ -406,7 +407,7 @@ get_current_locale_name (void)
                 */
 
                if (corrected == NULL) {
-                       corrected = malloc (strlen (locale));
+                       corrected = g_malloc (strlen (locale));
                        strncpy (corrected, locale, p - locale);
                        corrected [p - locale] = 0;
                }
@@ -693,16 +694,17 @@ static gint32 string_invariant_compare_char (gunichar2 c1, gunichar2 c2,
                                             gint32 options)
 {
        gint32 result;
-       GUnicodeType c1type, c2type;
 
        /* Ordinal can not be mixed with other options, and must return the difference, not only -1, 0, 1 */
        if (options & CompareOptions_Ordinal) 
                return (gint32) c1 - c2;
        
-       c1type = g_unichar_type (c1);
-       c2type = g_unichar_type (c2);
-       
        if (options & CompareOptions_IgnoreCase) {
+               GUnicodeType c1type, c2type;
+
+               c1type = g_unichar_type (c1);
+               c2type = g_unichar_type (c2);
+       
                result = (gint32) (c1type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c1) : c1) -
                        (c2type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c2) : c2);
        } else {