antirez / kilo

A text editor in less than 1000 LOC with syntax highlight and search.
BSD 2-Clause "Simplified" License
7.34k stars 807 forks source link

Question: Why kilo allocating 9 bytes memory for a non-printable character? #39

Open KiYugadgeter opened 8 years ago

KiYugadgeter commented 8 years ago

I am reading kilo code for learning C language. In line551, allocating 9 bytes memory for one non-printable character. Why 9 bytes memory need for a non-printable character?

And nonprint variable is only initialized to 0 at line 543, and it is not assigned to other value. So I think nonprint is not useful at line 551. What's the meaning of this?


row->render = malloc(row->size + tabs*8 + nonprint*9 + 1);

h4child commented 7 years ago

I don't know! But this already been removed https://github.com/practicalswift/openemacs/commit/469aadcb984ab693fe4a3cf9925790d0cf621f66 FORK

dirkf commented 3 years ago

The author probably intended to display non-printing characters something like <CTRL-D>. However ? is actually meant to be used, so the correct width is 1.