Free fonts on shutdown. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 89bfb55657c7381504115ef970090e3aa736c8b7
 (DIR) parent 6db38896e8c2d17bcd2a3534c26bf507f9614f3c
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Thu, 24 Nov 2016 23:52:22 -0600
       
       Free fonts on shutdown.
       
       Diffstat:
         libXg/xtbinit.c                     |       9 +++++++++
       
       1 file changed, 9 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c
       @@ -2,6 +2,7 @@
        #include <u.h>
        #include <libg.h>
        #include <stdio.h>
       +#include <stdlib.h>
        #include <string.h>
        #include "libgint.h"
        
       @@ -127,6 +128,13 @@ static uint8_t darkgreybits[] = {
        };
        
        void
       +freefont(void)
       +{
       +    if (font)
       +        XftFontClose(_dpy, font);
       +}
       +
       +void
        xtbinit(Errfunc f, char *class, int *pargc, char **argv, char **fallbacks)
        {
            int n;
       @@ -206,6 +214,7 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, char **fallbacks)
            screen.id = 0;
            XtRealizeWidget(_toplevel);
            _topwindow = XtWindow(_toplevel);
       +    atexit(freefont);
        
            pid_t pid = getpid();
            XChangeProperty(_dpy, XtWindow(_toplevel), XInternAtom(_dpy, "_NET_WM_PID", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1);