]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libdraw/subfont.c
libdraw: fix old subfont leak
[plan9front.git] / sys / src / libdraw / subfont.c
1 #include <u.h>
2 #include <libc.h>
3 #include <draw.h>
4
5 Subfont*
6 allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i)
7 {
8         Subfont *f;
9
10         assert(height != 0 /* allocsubfont */);
11
12         f = malloc(sizeof(Subfont));
13         if(f == 0)
14                 return 0;
15         f->n = n;
16         f->height = height;
17         f->ascent = ascent;
18         f->info = info;
19         f->bits = i;
20         f->ref = 1;
21         if(name){
22                 f->name = strdup(name);
23                 installsubfont(name, f);
24         }else
25                 f->name = 0;
26         return f;
27 }