Skip to content

c_format function looks redundant #178

@anutosh491

Description

@anutosh491

I don't see a function call to c_format. What is it being used for ? (can it be removed ?)

static std::string c_format(const char* format, std::va_list args)
{
// Call vsnprintf once to determine the required buffer length. The
// return value is the number of characters _excluding_ the null byte.
std::va_list args_bufsz;
va_copy(args_bufsz, args);
std::size_t bufsz = vsnprintf(NULL, 0, format, args_bufsz);
va_end(args_bufsz);
// Create an empty string of that size.
std::string s(bufsz, 0);
// Now format the data into this string and return it.
std::va_list args_format;
va_copy(args_format, args);
// The second parameter is the maximum number of bytes that vsnprintf
// will write _including_ the terminating null byte.
vsnprintf(&s[0], s.size() + 1, format, args_format);
va_end(args_format);
return s;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triageUsed in auto labelling of new issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions