diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-01 23:52:18 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-06 02:07:14 +0200 |
commit | 61f53e257de47e29fe3d6eec6d233552e8116cb4 (patch) | |
tree | bc13bf2dea0fa11cb25f969dedbe60bbb66f93e8 | |
parent | 8e929d4e369f687552db8d127b2d39947eb93983 (diff) | |
download | sparse-61f53e257de47e29fe3d6eec6d233552e8116cb4.tar.gz |
cleanup: move hexval() to utils.c
Now lib.c contains almost nothing else than library entrypoints.
Move a small utility, hexval(), to utils.c to complete this cleanup.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.c | 17 | ||||
-rw-r--r-- | lib.h | 2 | ||||
-rw-r--r-- | utils.c | 17 | ||||
-rw-r--r-- | utils.h | 4 |
4 files changed, 21 insertions, 19 deletions
@@ -50,23 +50,6 @@ #include "bits.h" -unsigned int hexval(unsigned int c) -{ - int retval = 256; - switch (c) { - case '0'...'9': - retval = c - '0'; - break; - case 'a'...'f': - retval = c - 'a' + 10; - break; - case 'A'...'F': - retval = c - 'A' + 10; - break; - } - return retval; -} - static void do_warn(const char *type, struct position pos, const char * fmt, va_list args) { static char buffer[512]; @@ -45,8 +45,6 @@ #endif -extern unsigned int hexval(unsigned int c); - struct position { unsigned int type:6, stream:14, @@ -8,6 +8,23 @@ #include <stdio.h> +unsigned int hexval(unsigned int c) +{ + int retval = 256; + switch (c) { + case '0'...'9': + retval = c - '0'; + break; + case 'a'...'f': + retval = c - 'a' + 10; + break; + case 'A'...'F': + retval = c - 'A' + 10; + break; + } + return retval; +} + void *xmemdup(const void *src, size_t len) { return memcpy(__alloc_bytes(len), src, len); @@ -9,6 +9,10 @@ #include <stdarg.h> /// +// return the value coresponding to an hexadecimal digit +unsigned int hexval(unsigned int c); + +/// // duplicate a memory buffer in a newly allocated buffer. // @src: a pointer to the memory buffer to be duplicated // @len: the size of the memory buffer to be duplicated |