aboutsummaryrefslogtreecommitdiff
path: root/lib/string/itoa.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-11-06 14:48:41 +0200
committeraqua <aqua@iserlohn-fortress.net>2022-11-06 15:03:06 +0200
commit6d53f16aa508c445309aa4ebe965baa9e17401a1 (patch)
treebf42dc7dc1105d819a83c1e5a8c8595df19401b6 /lib/string/itoa.c
parentlib/malloc: add linked list implementation (diff)
downloadkernel-6d53f16aa508c445309aa4ebe965baa9e17401a1.tar.xz
lib: migrate tests to gtest
Diffstat (limited to 'lib/string/itoa.c')
-rw-r--r--lib/string/itoa.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/string/itoa.c b/lib/string/itoa.c
index 3708be2..2db9768 100644
--- a/lib/string/itoa.c
+++ b/lib/string/itoa.c
@@ -4,18 +4,6 @@
static const char *numbers = "0123456789abcdef";
char *
-itoa(char *p, int x, int base)
-{
- const bool is_negative = (x < 0);
- if (is_negative) x = -x;
-
- p = utoa(p, x, base);
-
- if (is_negative) *--p = '-';
- return p;
-}
-
-char *
utoa(char *p, unsigned x, int base)
{
p += 3 * sizeof(unsigned);
@@ -28,3 +16,15 @@ utoa(char *p, unsigned x, int base)
return p;
}
+
+char *
+itoa(char *p, int x, int base)
+{
+ const bool is_negative = (x < 0);
+ if (is_negative) x = -x;
+
+ p = utoa(p, x, base);
+
+ if (is_negative) *--p = '-';
+ return p;
+}