diff --git a/src/stdlib.c b/src/stdlib.c index e770c8e..4a373f6 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -37,7 +37,8 @@ if ((base > max_base) || (base < 0)) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -46,7 +47,8 @@ if (*str == 0) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -58,7 +60,8 @@ str++; if (*str == 0) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -78,7 +81,8 @@ } else { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } } @@ -107,7 +111,8 @@ str++; } - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return val; } @@ -120,7 +125,8 @@ if ((base > max_base) || (base < 0)) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -129,7 +135,8 @@ if (*str == 0) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -151,7 +158,8 @@ str++; if (*str == 0) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -171,7 +179,8 @@ } else { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } } @@ -200,7 +209,8 @@ str++; } - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; if (negative) return -val; @@ -217,7 +227,8 @@ if (*str == 0) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; return 0; } @@ -262,7 +273,8 @@ if (*str) { - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; if (negative) return -val; @@ -271,8 +283,8 @@ } } - - *endptr = (char*)str; + if (endptr) + *endptr = (char*)str; if (negative) return -val; @@ -284,15 +296,13 @@ int32_t atoi(const char* str) { - char* endptr; - return (int32_t)strtol(str, &endptr, 10); + return (int32_t)strtol(str, NULL, 10); } int64_t atol(const char* str) { - char* endptr; - return strtol(str, &endptr, 10); + return strtol(str, NULL, 10); }