summaryrefslogtreecommitdiff
path: root/utils/static_utoa.h
blob: d15ed35b751543fd3943de200b180382a5eb1476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef STATIC_UTOA_H
#define STATIC_UTOA_H

#include "threadlocal.h"
#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);
}

#endif