From b8284137d4e0eec11c78bc14047243fce6a51373 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 6 Sep 2020 15:47:06 -0400 Subject: minor changes, redoing makefile, meminfo program --- src/user/knob/format.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/user/knob/format.c') diff --git a/src/user/knob/format.c b/src/user/knob/format.c index f55e857..087f6fd 100644 --- a/src/user/knob/format.c +++ b/src/user/knob/format.c @@ -10,4 +10,22 @@ bool try_sntoi(const char *s, uint32_t n, uint32_t *out) { } *out = calc; return true; +} + +void itosz(uint32_t i, char *out) { + if (!i) { + *(uint16_t *)out = (uint16_t)'0'; + return; + } + bool zero = false; + for (uint32_t m = 1000000000; m; m /= 10) { + uint8_t d = (i / m) % 10; + if (zero) + *(out++) = d + '0'; + else if (d) { + zero = true; + *(out++) = d + '0'; + } + } + *out = '\0'; } \ No newline at end of file -- cgit v1.2.3