scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

vsprintf.c (510B)


      1 #include <stdarg.h>
      2 #include <stdint.h>
      3 #include <stdio.h>
      4 
      5 #undef vsprintf
      6 
      7 int
      8 vsprintf(char *restrict s, const char *restrict fmt, va_list va)
      9 {
     10 	/*
     11 	 * we used to use SIZE_MAX here, but that is just
     12 	 * wrong because we build a rp pointer that in that
     13 	 * case it is just wp - 1 by definition. As it
     14 	 * is impossible to span an object further than
     15 	 * the end of the memory space we can use the number
     16 	 * of bytes until the end of the address space.
     17 	 */
     18 	return vsnprintf(s, (char *)-1 - s, fmt, va);
     19 }