diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-02 11:01:12 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-02 11:01:12 +0100 |
commit | 2259f3fb9aebb2973ee2d892bec944f177a41c64 (patch) | |
tree | 79dce66d2ebc573ae4e29468ae7d63cc5317da3f /sys/src/libdraw/mkfont.c | |
parent | fc1ff7705b339d480f15fa934c7df215158c1901 (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/mkfont.c')
-rw-r--r-- | sys/src/libdraw/mkfont.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/src/libdraw/mkfont.c b/sys/src/libdraw/mkfont.c index df6b0ec2f..56b0aea4e 100644 --- a/sys/src/libdraw/mkfont.c +++ b/sys/src/libdraw/mkfont.c @@ -12,8 +12,8 @@ mkfont(Subfont *subfont, Rune min) Cachefont *c; font = malloc(sizeof(Font)); - if(font == 0) - return 0; + if(font == nil) + return nil; memset(font, 0, sizeof(Font)); font->display = subfont->bits->display; font->name = strdup("<synthetic>"); @@ -21,7 +21,7 @@ mkfont(Subfont *subfont, Rune min) font->nsubf = NFSUBF; font->cache = malloc(font->ncache * sizeof(font->cache[0])); font->subf = malloc(font->nsubf * sizeof(font->subf[0])); - if(font->name==0 || font->cache==0 || font->subf==0){ + if(font->name==nil || font->cache==nil || font->subf==nil){ Err: free(font->name); free(font->cache); @@ -36,18 +36,18 @@ mkfont(Subfont *subfont, Rune min) font->ascent = subfont->ascent; font->age = 1; font->sub = malloc(sizeof(Cachefont*)); - if(font->sub == 0) + if(font->sub == nil) goto Err; c = malloc(sizeof(Cachefont)); - if(c == 0) + if(c == nil) goto Err; font->nsub = 1; font->sub[0] = c; c->min = min; c->max = min+subfont->n-1; c->offset = 0; - c->name = 0; /* noticed by freeup() and agefont() */ - c->subfontname = 0; + c->name = nil; /* noticed by agefont() */ + c->subfontname = nil; font->subf[0].age = 0; font->subf[0].cf = c; font->subf[0].f = subfont; |