[dev] [sbase] afgets

From: Truls Becken <truls.becken_AT_gmail.com>
Date: Sun, 7 Jul 2013 00:30:19 +0200

Greetings.

In afgets() the size variable is never updated, which usually means it is always
zero, in which case it has no purpose at all. I believe it is supposed to be
updated on realloc? This way, calling afgets multiple times with the same
arguments will reuse the space if possible.

Also, the return value is just a dereference of the pointer argument, which is
not very useful. Why not return len instead, so the caller does not have to
use strlen to get the length? All current uses of afgets() only check for a
non-zero return value, which would work equally well if length is returned.

Proposed change attached.

-Truls


Received on Sun Jul 07 2013 - 00:30:19 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 07 2013 - 00:36:06 CEST