From afa2ffd81eeb31b2594c96556768ca17c3bb3cfc Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 25 Jun 2012 14:16:11 +0400 Subject: [PATCH] * xfns.c (xic_create_fontsetname): Remove redundant calls to memset. --- src/ChangeLog | 5 +++++ src/xfns.c | 20 +++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 95c938d7a68..1430c479c97 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-06-25 Dmitry Antipov + + * xfns.c (xic_create_fontsetname): Remove redundant calls + to memset. + 2012-06-25 Paul Eggert * gtkutil.c (get_utf8_string): Remove redundant assignment. diff --git a/src/xfns.c b/src/xfns.c index b5d0102486c..575d9434c76 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1881,10 +1881,9 @@ xic_create_fontsetname (const char *base_fontname, int motif) /* Make a fontset name from the base font name. */ if (xic_default_fontset == base_fontname) - { /* There is no base font name, use the default. */ - ptrdiff_t len = strlen (base_fontname) + 2; - fontsetname = xmalloc (len); - memset (fontsetname, 0, len); + { + /* There is no base font name, use the default. */ + fontsetname = xmalloc (strlen (base_fontname) + 2); strcpy (fontsetname, base_fontname); } else @@ -1900,13 +1899,12 @@ xic_create_fontsetname (const char *base_fontname, int motif) for (i = 0; *p; p++) if (*p == '-') i++; if (i != 14) - { /* As the font name doesn't conform to XLFD, we can't + { + /* As the font name doesn't conform to XLFD, we can't modify it to generalize it to allcs and allfamilies. Use the specified font plus the default. */ - ptrdiff_t len = - strlen (base_fontname) + strlen (xic_default_fontset) + 3; - fontsetname = xmalloc (len); - memset (fontsetname, 0, len); + fontsetname = xmalloc (strlen (base_fontname) + + strlen (xic_default_fontset) + 3); strcpy (fontsetname, base_fontname); strcat (fontsetname, sep); strcat (fontsetname, xic_default_fontset); @@ -1956,7 +1954,6 @@ xic_create_fontsetname (const char *base_fontname, int motif) /* Build the font spec that matches all charsets. */ len = p - base_fontname + strlen (allcs) + 1; font_allcs = (char *) alloca (len); - memset (font_allcs, 0, len); memcpy (font_allcs, base_fontname, p - base_fontname); strcat (font_allcs, allcs); @@ -1964,7 +1961,6 @@ xic_create_fontsetname (const char *base_fontname, int motif) add-styles. */ len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1; font_allfamilies = (char *) alloca (len); - memset (font_allfamilies, 0, len); strcpy (font_allfamilies, allfamilies); memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); strcat (font_allfamilies, allcs); @@ -1972,7 +1968,6 @@ xic_create_fontsetname (const char *base_fontname, int motif) /* Build the font spec that matches all. */ len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; font_all = (char *) alloca (len); - memset (font_all, 0, len); strcpy (font_all, allfamilies); strcat (font_all, all); memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); @@ -1982,7 +1977,6 @@ xic_create_fontsetname (const char *base_fontname, int motif) len = strlen (base_fontname) + strlen (font_allcs) + strlen (font_allfamilies) + strlen (font_all) + 5; fontsetname = xmalloc (len); - memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); strcat (fontsetname, sep); strcat (fontsetname, font_allcs); -- 2.39.2