I was just after help on my question
I also didn't want to get into complications, but the explanation is in the 1st link in my 1st post. I currently have vsprintf but it isn't thread-safe because it lives in the ST-supplied libc.a standard C library which uses (probably) statics and (certainly) the heap. And whether you like it or not, people do use sprintf and vsprintf, and if they do they will get all sorts of funny problems. My sprintf is however thread-safe because I have a nice library for most of these, but it doesn't have vsprintf.
So I have two options: create a vsprintf from one of the other (thread-safe) functions, or undefine it so people can't use it. I tried removing it from the ST lib (objcopy strip symbol option) but that doesn't work because that lib (compiled, no source) has vsprintf defined (it has the code for it) and objcopy doesn't allow the symbol removal in such a case.
Is it hard to get a vsprintf from sprintf, with a function, or a macro?
For example, I have the following from that open source printf.c mentioned earlier. A "v" function calls va_start and va_end around the printf.
...
I'm just really not able to understand what you are getting hung up on.
In your first post you said you have vsnprintf available.
In the code you listed above, vsnprintf is there.
Why can you not simply use vsnprintf?
For example, vsprintf looks like this:
int vsprintf (char * s, const char * format, va_list arg );
While vsnprintf is like this:
int vsnprintf (char * s, size_t n, const char * format, va_list arg );
The only difference is the size of the output buffer, n. If you don't know the size of the buffer, just put in a big arbitrary number for n, like 10000 or something. If you complain that this is unreasonable and it may cause a buffer overrun, well this is exactly why you shouldn't be using the unsafe version in the first place.
Also, if you don't know the size of the buffer, the code is already in big trouble.