You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of get_double and the similar functions initializes the va_list ap at the beginning of the function and cleans it up before each return statement. This seems unnecessarily complicated and error-prone. (The current implementation is fine, it just has potential to become erroneous.)
A simpler way would be:
while (true)
{
// Get line of text
va_list ap;
va_start(ap, format);
string line = get_string(&ap, format);
va_end(ap);
// Return DBL_MAX on failure
if (line == NULL)
{
return DBL_MAX;
}
This code has the benefit of making the actual scope of ap smaller than before, and of pairing the va_start with the va_end in an obvious way.
Is there a compelling reason for the current implementation?
The text was updated successfully, but these errors were encountered:
The implementation of
get_double
and the similar functions initializes theva_list ap
at the beginning of the function and cleans it up before eachreturn
statement. This seems unnecessarily complicated and error-prone. (The current implementation is fine, it just has potential to become erroneous.)A simpler way would be:
This code has the benefit of making the actual scope of
ap
smaller than before, and of pairing theva_start
with theva_end
in an obvious way.Is there a compelling reason for the current implementation?
The text was updated successfully, but these errors were encountered: