summaryrefslogtreecommitdiff
path: root/pango/pango-language.c
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2020-03-04 13:19:02 +0100
committerTimm Bäder <tbaeder@redhat.com>2020-04-14 16:36:23 +0200
commit3a9398fb989ff571aa40405987e20d548717687e (patch)
treea5ef369c3b27b22e7063aa9ed5fee9bac4259616 /pango/pango-language.c
parent3d6c8f0bd97171f9409f900f94e694fffecb739f (diff)
downloadpango-3a9398fb989ff571aa40405987e20d548717687e.tar.gz
PangoLanguage: Fix clang -Wcast-align warnings
Clang complains when casting char* to PangoLanguage* and -Wcast-align set. We only cast it to char* to get the proper address for the private struct though, so just cast to void* afterwards. Except for the case that was stuffing PangoLanguage* sized elements into a GArray. Just use a GPtrArray there.
Diffstat (limited to 'pango/pango-language.c')
-rw-r--r--pango/pango-language.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/pango/pango-language.c b/pango/pango-language.c
index 575d4652..ed8b0195 100644
--- a/pango/pango-language.c
+++ b/pango/pango-language.c
@@ -66,7 +66,7 @@ pango_language_get_private (PangoLanguage *language)
if (!language)
return NULL;
- priv = (PangoLanguagePrivate *) ((char *)language - sizeof (PangoLanguagePrivate));
+ priv = (PangoLanguagePrivate *) ((void *)((char *)language - sizeof (PangoLanguagePrivate)));
if (G_UNLIKELY (priv->magic != PANGO_LANGUAGE_PRIVATE_MAGIC))
{
@@ -331,7 +331,7 @@ pango_language_from_string (const char *language)
G_LOCK_DEFINE_STATIC (lang_from_string);
static GHashTable *hash = NULL; /* MT-safe */
PangoLanguagePrivate *priv;
- char *result;
+ void *result;
int len;
char *p;
@@ -354,7 +354,7 @@ pango_language_from_string (const char *language)
g_assert (result);
priv = (PangoLanguagePrivate *) result;
- result += sizeof (*priv);
+ result = ((char *)result) + sizeof (*priv);
pango_language_private_init (priv);
@@ -749,7 +749,7 @@ parse_default_languages (void)
{
char *p, *p_copy;
gboolean done = FALSE;
- GArray *langs;
+ GPtrArray *langs;
p = getenv ("PANGO_LANGUAGE");
@@ -761,34 +761,34 @@ 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)
{
char *end = strpbrk (p, LANGUAGE_SEPARATORS);
if (!end)
- {
- end = p + strlen (p);
- done = TRUE;
- }
+ {
+ end = p + strlen (p);
+ done = TRUE;
+ }
else
*end = '\0';
/* skip empty languages, and skip the language 'C' */
if (p != end && !(p + 1 == end && *p == 'C'))
{
- PangoLanguage *l = pango_language_from_string (p);
-
- g_array_append_val (langs, l);
- }
+ PangoLanguage *l = pango_language_from_string (p);
+
+ g_ptr_array_add (langs, l);
+ }
if (!done)
- p = end + 1;
+ p = end + 1;
}
g_free (p_copy);
- return (PangoLanguage **) g_array_free (langs, FALSE);
+ return (PangoLanguage **) g_ptr_array_free (langs, FALSE);
}
static PangoLanguage *