summaryrefslogtreecommitdiff
path: root/sys/src/libdraw/font.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-03-02 11:01:12 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-03-02 11:01:12 +0100
commit2259f3fb9aebb2973ee2d892bec944f177a41c64 (patch)
tree79dce66d2ebc573ae4e29468ae7d63cc5317da3f /sys/src/libdraw/font.c
parentfc1ff7705b339d480f15fa934c7df215158c1901 (diff)
libdraw: font->display->defaultsubfont vs. display->defaultsubfont, dead code, malloc erros
it is possible to have fonts belong to different or no display, so the check for defaultsubfont has to be against font->display, not the global display variable. remove unused freeup() routine. handle strdup() error in allocsubfont() and realloc() error in buildfont().
Diffstat (limited to 'sys/src/libdraw/font.c')
-rw-r--r--sys/src/libdraw/font.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/sys/src/libdraw/font.c b/sys/src/libdraw/font.c
index 7247c9a92..ed996e448 100644
--- a/sys/src/libdraw/font.c
+++ b/sys/src/libdraw/font.c
@@ -3,7 +3,6 @@
#include <draw.h>
static int fontresize(Font*, int, int, int);
-static int freeup(Font*);
#define PJW 0 /* use NUL==pjw for invisible characters */
@@ -129,7 +128,7 @@ agefont(Font *f)
if(s->age){
if(s->age<SUBFAGE && s->cf->name != nil){
/* clean up */
- if(display == nil || s->f != display->defaultsubfont)
+ if(f->display == nil || s->f != f->display->defaultsubfont)
freesubfont(s->f);
s->cf = nil;
s->f = nil;
@@ -316,32 +315,6 @@ loadchar(Font *f, Rune r, Cacheinfo *c, int h, int noflush, char **subfontname)
return 1;
}
-/* release all subfonts, return number freed */
-static
-int
-freeup(Font *f)
-{
- Cachesubf *s, *es;
- int nf;
-
- if(f->sub[0]->name == nil) /* font from mkfont; don't free */
- return 0;
- s = f->subf;
- es = s+f->nsubf;
- nf = 0;
- while(s < es){
- if(s->age){
- freesubfont(s->f);
- s->cf = nil;
- s->f = nil;
- s->age = 0;
- nf++;
- }
- s++;
- }
- return nf;
-}
-
/* returns whether resize succeeded && f->cache is unchanged */
static int
fontresize(Font *f, int wid, int ncache, int depth)