[linux] eliminate VLAs

pull/2303/head
nick black 3 years ago
parent 80153f804d
commit b5e4b58902
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -364,8 +364,9 @@ program_line_drawing_chars(int fd, struct unimapdesc* map){
for(size_t sidx = 0 ; sidx < sizeof(sets) / sizeof(*sets) ; ++sidx){
int fontidx = -1;
struct simset* s = &sets[sidx];
bool found[wcslen(s->ws)];
memset(found, 0, sizeof(found));
size_t fsize = sizeof(bool) * wcslen(s->ws);
bool* found = malloc(fsize);
memset(found, 0, fsize);
for(unsigned idx = 0 ; idx < map->entry_ct ; ++idx){
for(size_t widx = 0 ; widx < wcslen(s->ws) ; ++widx){
if(map->entries[idx].unicode == s->ws[widx]){
@ -390,6 +391,7 @@ program_line_drawing_chars(int fd, struct unimapdesc* map){
}else{
logwarn("Couldn't find any glyphs for set %zu\n", sidx);
}
free(found);
}
if(toadd == 0){
return 0;

@ -69,7 +69,7 @@ get_linux_colormap(int fd){
//
// height * rowbytes, where rowbytes = width + 7 / 8
static int
explode_glyph_row(const unsigned char** row, unsigned width){
explode_glyph_row(unsigned char** row, unsigned width){
unsigned char mask = 0x80;
while(width--){
printf("%s", **row & mask ? "*" : " ");
@ -110,7 +110,7 @@ get_linux_consolefont(int fd, unsigned showglyphs){
// FIXME get real screen width
const int atonce = 80 / (cfo.width + 1);
const int Bper = 64;
const unsigned char* g[atonce];
unsigned char** g = malloc(sizeof(*g) * atonce);
for(unsigned i = 0 ; i < cfo.charcount ; i += atonce){
for(int o = 0 ; o < atonce ; ++o){
g[o] = (unsigned char*)cfo.data + Bper * (i + o);
@ -122,6 +122,7 @@ get_linux_consolefont(int fd, unsigned showglyphs){
printf("\n");
}
}
free(g);
}
free(cfo.data);
return 0;

Loading…
Cancel
Save