[hackers] [st] simplify (greedy) font caching allocating a bit || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 3 Mar 2019 11:36:06 +0100 (CET)

commit ed68fe7dce2b21b4e0e595b99d47790e76812cb7
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sun Mar 3 11:29:43 2019 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sun Mar 3 11:29:43 2019 +0100

    simplify (greedy) font caching allocating a bit
    
    POSIX says:
    "If ptr is a null pointer, realloc() shall be equivalent to malloc() for the
     specified size."

diff --git a/x.c b/x.c
index aa86b31..5828a3b 100644
--- a/x.c
+++ b/x.c
_AT_@ -1243,15 +1243,10 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
                         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 (!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,
Received on Sun Mar 03 2019 - 11:36:06 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 03 2019 - 11:36:34 CET