Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

char buf[LINE_MAX]

Name: Anonymous 2008-08-26 6:39

Why do programmers still code in arbitrary limits like these?

It breaks when you do
#define LINE_MAX UINT_MAX

Why not redesign so that you use an O(1) space algorithm, or if it can't be avoided, dynamically allocate as much as needed?

Name: Anonymous 2008-08-26 13:17

>>4
If your program gives up at some number far below the capabilities of the hardware, it's not scalable enough. If I have a 32-bit machine I expect e.g. uniq to easily deal with files containing lines several hundred million characters long, if I have enough memory (virtual or not). And if I'm on a 64-bit machine with a terabyte of RAM, lines in the gigacharacter range should be possible to process -- what's the point of having an extra 32 bits if you can't even use it?

>>8,9
Just resize the buffer dynamically, up to a certain size. Networking is different -- you need to set a maximum, or someone will DoS not by overflowing the buffer, but by making it grow as big as possible to consume all memory. And that's also what ulimits are for.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List