diff options
author | Marvin Borner | 2019-10-02 20:01:17 +0200 |
---|---|---|
committer | Marvin Borner | 2019-10-02 20:01:17 +0200 |
commit | 3238ced93283a167675f20244ec9fd6310eb8002 (patch) | |
tree | 288078ca30e9e4b5d5ba9a178315cb5ee9f6a2d8 /src/kernel/lib | |
parent | 682c47a98844ffec3f3129160e9cdb98ba129989 (diff) |
Finally fixed VESA auto resolution finder
This was quite hard and strange but it works now!
Diffstat (limited to 'src/kernel/lib')
-rw-r--r-- | src/kernel/lib/lib.h | 4 | ||||
-rw-r--r-- | src/kernel/lib/string.c | 29 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/kernel/lib/lib.h b/src/kernel/lib/lib.h index d6cc09e..0292cc3 100644 --- a/src/kernel/lib/lib.h +++ b/src/kernel/lib/lib.h @@ -65,8 +65,8 @@ int memory_compare(const void *a_ptr, const void *b_ptr, size_t size); * Convert an int into a string * @param i The integer which should be converted * @param b The converted int as string - * @return The converted string (b) + * @param base The desired base */ -char *itoa(int i, char b[]); +void *itoa(int i, char *b, int base); #endif diff --git a/src/kernel/lib/string.c b/src/kernel/lib/string.c index f07697d..ef746d6 100644 --- a/src/kernel/lib/string.c +++ b/src/kernel/lib/string.c @@ -35,22 +35,19 @@ char *strcpy(char *dest, const char *src) { return dest; } -char *itoa(int i, char b[]) { - char const digit[] = "0123456789"; - char *p = b; - if (i < 0) { - *p++ = '-'; - i *= -1; +void *itoa(int i, char *b, int base) { + int temp_i; + temp_i = i; + int stringLen = 1; + + while ((int) temp_i / base != 0) { + temp_i = (int) temp_i / base; + stringLen++; } - int shifter = i; - do { - ++p; - shifter = shifter / 10; - } while (shifter); - *p = '\0'; + + temp_i = i; do { - *--p = digit[i % 10]; - i = i / 10; - } while (i); - return b; + *(b + stringLen - 1) = (temp_i % base) + '0'; + temp_i = (int) temp_i / base; + } while (stringLen--); }
\ No newline at end of file |