[pango/matthiasc/for-master: 1/4] language: Silence compiler warnings




commit ad1262d9a22ac2d35bc1075748b8b47aaf144711
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 10 10:20:54 2021 -0400

    language: Silence compiler warnings
    
    Use a GPtrArray instead of a GArray of pointers,
    to avoid case-align warnings.

 pango/pango-language.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/pango/pango-language.c b/pango/pango-language.c
index bf492a9e..3370bc41 100644
--- a/pango/pango-language.c
+++ b/pango/pango-language.c
@@ -347,11 +347,11 @@ pango_language_from_string (const char *language)
     }
 
   len = strlen (language);
-  result = g_malloc0 (sizeof (PangoLanguagePrivate) + len + 1);
-  g_assert (result);
+  priv = g_malloc0 (sizeof (PangoLanguagePrivate) + len + 1);
+  g_assert (priv);
 
-  priv = (PangoLanguagePrivate *) result;
-  result += sizeof (*priv);
+  result = (char *)priv;
+  result += sizeof (PangoLanguagePrivate);
 
   pango_language_private_init (priv);
 
@@ -746,7 +746,7 @@ parse_default_languages (void)
 {
   char *p, *p_copy;
   gboolean done = FALSE;
-  GArray *langs;
+  GPtrArray *langs;
 
   p = getenv ("PANGO_LANGUAGE");
 
@@ -758,7 +758,7 @@ parse_default_languages (void)
 
   p_copy = p = g_strdup (p);
 
-  langs = g_array_new (TRUE, FALSE, sizeof (PangoLanguage *));
+  langs = g_ptr_array_new ();
 
   while (!done)
     {
@@ -776,16 +776,18 @@ parse_default_languages (void)
         {
          PangoLanguage *l = pango_language_from_string (p);
          
-         g_array_append_val (langs, l);
+         g_ptr_array_add (langs, l);
        }
 
       if (!done)
        p = end + 1;
     }
 
+  g_ptr_array_add (langs, NULL);
+
   g_free (p_copy);
 
-  return (PangoLanguage **) g_array_free (langs, FALSE);
+  return (PangoLanguage **) g_ptr_array_free (langs, FALSE);
 }
 
 G_LOCK_DEFINE_STATIC (languages);
@@ -858,7 +860,7 @@ pango_language_get_preferred (void)
   /* We call this just for its side-effect of initializing languages */
   _pango_script_get_default_language (PANGO_SCRIPT_COMMON);
 
-  return languages;
+  return (PangoLanguage **) languages;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]