fbcon: properly use fbuf

pull/2122/head
nick black 3 years ago
parent b13ecb31f9
commit bdc593a8ff
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -155,6 +155,14 @@ fbuf_reset(fbuf* f){
f->used = 0; f->used = 0;
} }
static inline int
fbuf_reserve(fbuf* f, size_t len){
if(fbuf_grow(f, len)){
return -1;
}
return 0;
}
static inline int static inline int
fbuf_putc(fbuf* f, char c){ fbuf_putc(fbuf* f, char c){
if(fbuf_grow(f, 1)){ if(fbuf_grow(f, 1)){

@ -39,8 +39,7 @@ int fbcon_blit(struct ncplane* n, int linesize, const void* data,
int cdimy = s->cellpxy; int cdimy = s->cellpxy;
// FIXME this will need be a copy of the tinfo's fbuf map // FIXME this will need be a copy of the tinfo's fbuf map
size_t flen = leny * lenx * 4; size_t flen = leny * lenx * 4;
s->glyph.buf = malloc(flen); if(fbuf_reserve(&s->glyph, flen)){
if(s->glyph.buf == NULL){
return -1; return -1;
} }
tament* tam = NULL; tament* tam = NULL;
@ -114,7 +113,7 @@ error:
if(!reuse){ if(!reuse){
free(tam); free(tam);
} }
free(s->glyph.buf); fbuf_free(&s->glyph);
s->glyph.size = 0; s->glyph.size = 0;
return -1; return -1;
} }

Loading…
Cancel
Save