]> git.armaanb.net Git - st.git/commitdiff
simplify (greedy) font caching allocating a bit
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 3 Mar 2019 10:29:43 +0000 (11:29 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 3 Mar 2019 10:29:43 +0000 (11:29 +0100)
POSIX says:
"If ptr is a null pointer, realloc() shall be equivalent to malloc() for the
 specified size."

x.c

diff --git a/x.c b/x.c
index aa86b31ec860664bba40ebcca7c1d7a7cfd13854..5828a3b1a42ee0fa1fd04ced06515eca05eb5651 100644 (file)
--- a/x.c
+++ b/x.c
@@ -1243,15 +1243,10 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
                        fontpattern = FcFontSetMatch(0, fcsets, 1,
                                        fcpattern, &fcres);
 
                        fontpattern = FcFontSetMatch(0, fcsets, 1,
                                        fcpattern, &fcres);
 
-                       /*
-                        * Allocate memory for the new cache entry.
-                        */
+                       /* Allocate memory for the new cache entry. */
                        if (frclen >= frccap) {
                                frccap += 16;
                        if (frclen >= frccap) {
                                frccap += 16;
-                               if (!frc)
-                                       frc = xmalloc(frccap * sizeof(Fontcache));
-                               else
-                                       frc = xrealloc(frc, frccap * sizeof(Fontcache));
+                               frc = xrealloc(frc, frccap * sizeof(Fontcache));
                        }
 
                        frc[frclen].font = XftFontOpenPattern(xw.dpy,
                        }
 
                        frc[frclen].font = XftFontOpenPattern(xw.dpy,