[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: memstat-0.9 hurd patch (PATH_MAX)

2012/1/24 Tanguy LE CARROUR <tanguy.lecarrour@gmail.com>:
> The indentation is really strange! For example, line 112 from the original
> memstat.c: (tab '------>', space '.')
> ------->....if (errno != 0) {
> ------->------->perror("strtol");
> ................exit(1);
> ............}
> Does it make any sense?!

It does when tabs are displayed as 8 spaces, though it is inconsistent
wrt. some tabs being expanded as spaces.

>> - fgets(buf + last, buf_size - last, f); then you can realloc
>> unconditionally
> I still need to check if the buffer size needs to be increased, or I'll
> increase it each time I read a part of the line?!
> if (buf_size < last + BUFSIZ + 1) {

You'll double the size each time, it's okay.

> This may not be a problem as line are "supposed" to be "short" and buffer is
> "big", but if I had a 10 char. buffer on a 1000 char. line I would end up
> with a BIG buffer, wouldn't I?

1280 bytes, after 7 iterations.

> I hope I've fixed everything, except for the "to increase or not to increase
> the buffer" on each iteration in the get_line().

Looks fine,
Jérémie Koenig <jk@jk.fr.eu.org>

Reply to: