summaryrefslogtreecommitdiffstats
path: root/libnetdata/buffer
diff options
context:
space:
mode:
Diffstat (limited to 'libnetdata/buffer')
-rw-r--r--libnetdata/buffer/README.md3
-rw-r--r--libnetdata/buffer/buffer.c42
2 files changed, 27 insertions, 18 deletions
diff --git a/libnetdata/buffer/README.md b/libnetdata/buffer/README.md
index 5a9d7b023..c5f66e6e3 100644
--- a/libnetdata/buffer/README.md
+++ b/libnetdata/buffer/README.md
@@ -13,5 +13,4 @@ Also, they are super fast in printing and appending data to the string and its `
is just a lookup (it does not traverse the string).
Netdata uses `BUFFER`s for preparing web responses and buffering data to be sent upstream or
-to backend databases.
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Flibnetdata%2Fbuffer%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+to external databases.
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c
index c37da21e1..8ea90985c 100644
--- a/libnetdata/buffer/buffer.c
+++ b/libnetdata/buffer/buffer.c
@@ -87,14 +87,19 @@ inline char *print_number_llu_r(char *str, unsigned long long uvalue) {
}
inline char *print_number_llu_r_smart(char *str, unsigned long long uvalue) {
-#ifdef ENVIRONMENT32
- if(uvalue > (unsigned long long)0xffffffff)
- str = print_number_llu_r(str, uvalue);
- else
- str = print_number_lu_r(str, uvalue);
-#else
- do *str++ = (char)('0' + (uvalue % 10)); while(uvalue /= 10);
-#endif
+ switch (sizeof(void *)) {
+ case 4:
+ str = (uvalue > (unsigned long long) 0xffffffff) ? print_number_llu_r(str, uvalue) :
+ print_number_lu_r(str, uvalue);
+ break;
+ case 8:
+ do {
+ *str++ = (char) ('0' + (uvalue % 10));
+ } while (uvalue /= 10);
+ break;
+ default:
+ fatal("Netdata supports only 32-bit & 64-bit systems.");
+ }
return str;
}
@@ -106,14 +111,19 @@ void buffer_print_llu(BUFFER *wb, unsigned long long uvalue)
char *str = &wb->buffer[wb->len];
char *wstr = str;
-#ifdef ENVIRONMENT32
- if(uvalue > (unsigned long long)0xffffffff)
- wstr = print_number_llu_r(wstr, uvalue);
- else
- wstr = print_number_lu_r(wstr, uvalue);
-#else
- do *wstr++ = (char)('0' + (uvalue % 10)); while(uvalue /= 10);
-#endif
+ switch (sizeof(void *)) {
+ case 4:
+ wstr = (uvalue > (unsigned long long) 0xffffffff) ? print_number_llu_r(wstr, uvalue) :
+ print_number_lu_r(wstr, uvalue);
+ break;
+ case 8:
+ do {
+ *wstr++ = (char) ('0' + (uvalue % 10));
+ } while (uvalue /= 10);
+ break;
+ default:
+ fatal("Netdata supports only 32-bit & 64-bit systems.");
+ }
// terminate it
*wstr = '\0';