7 ms·
The alloca usage here terrifies me.
by wmobit 15y ago
The alloca usage here terrifies me.
- burgerbrain 15y agoThat is a good point. I don't know if write has a limit on 'count' (I can't find anything saying that it does), but if it's simply "whatever you can fit in size_t" then you certainly want to be careful about putting that on your stack. Failed alloca's don't really give you any indication, though you might sigsegv later.
- sickill 15y agoWhat would you suggest instead then? I'm not C programmer.
- burgerbrain 15y agoAvoid the allocation entirely. Use writev for example (or just use multiple 'write's, if you don't care about it being atomic).
- sickill 15y agoThx. Improved version in master: https://github.com/sickill/stderred/blob/master/stderred.c https://github.com/sickill/stderred/blob/master/stderred.c