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().
This commit is contained in:
cinap_lenrek 2015-03-02 11:01:12 +01:00
parent fc1ff7705b
commit 2259f3fb9a
4 changed files with 32 additions and 57 deletions

View file

@ -10,8 +10,8 @@ allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i
assert(height != 0 /* allocsubfont */);
f = malloc(sizeof(Subfont));
if(f == 0)
return 0;
if(f == nil)
return nil;
f->n = n;
f->height = height;
f->ascent = ascent;
@ -20,8 +20,12 @@ allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i
f->ref = 1;
if(name){
f->name = strdup(name);
if(f->name == nil){
free(f);
return nil;
}
installsubfont(name, f);
}else
f->name = 0;
f->name = nil;
return f;
}