Given that such a function does not exist, consider a slightly different approach: make writeLog printf-like, i.e. take a string and a variable number of arguments. Then format the message inside. This solves the memory management issue and does not violate the existing use of writeLog .
If you find this possible, you can use something on these lines:
void writeLog(const char* format, ...) { char msg[100]; va_list args; va_start(args, format); vsnprintf(msg, sizeof(msg), format, args);
eran
source share