Chris Down writes:
>>and maybe fgets can simply be rewritten using getline() at:
>>
>> http://git.suckless.org/sent/file/sent.c.html#l417
>
>Hmm, unless I'm missing something, getline() actually would hinder
>here since we need to use separate heap storage for each line, but
>getline() optimises for the case where `char **lineptr` can be reused
>for each line. As such we'd still have to strdup(), or entries in
>s->lines would always end up being the same.
Oh, I think I see what you mean now. :-)
Patch attached, not sure it's simpler though since it requires all this futzing
around with buf and n.
Received on Wed May 13 2020 - 13:47:04 CEST