diff options
Diffstat (limited to 'utils/static_utoa.h')
-rwxr-xr-x | utils/static_utoa.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/utils/static_utoa.h b/utils/static_utoa.h index 3af9fbb6..d15ed35b 100755 --- a/utils/static_utoa.h +++ b/utils/static_utoa.h @@ -5,35 +5,19 @@ #include "utoa.h" namespace { +static const int utoa_bufsize=40; // 64bit safe. +static const int utoa_bufsizem1=utoa_bufsize-1; // 64bit safe. THREADLOCAL char utoa_buf[utoa_bufsize]; // to put end of string character at buf[20] } inline char *static_utoa(unsigned n) { + assert(utoa_buf[utoa_bufsizem1]==0); return utoa(utoa_buf+utoa_bufsizem1,n); } inline char *static_itoa(int n) { + assert(utoa_buf[utoa_bufsizem1]==0); return itoa(utoa_buf+utoa_bufsizem1,n); } -#ifdef ITOA_SAMPLE -# include <cstdio> -# include <sstream> -# include <iostream> -using namespace std; - -int main(int argc,char *argv[]) { - printf("d U d U d U\n"); - for (int i=1;i<argc;++i) { - int n; - unsigned un; - sscanf(argv[i],"%d",&n); - sscanf(argv[i],"%u",&un); - printf("%d %u %s",n,un,static_itoa(n)); - printf(" %s %s %s\n",static_utoa(un),itos(n).c_str(),utos(un).c_str()); - } - return 0; -} -#endif - #endif |