atoi: remove atoi usage

This commit is contained in:
Yang Tse 2010-11-28 23:11:14 +01:00
parent cbe67a1b71
commit 5db0a412ff
12 changed files with 36 additions and 22 deletions

View file

@ -59,7 +59,10 @@ int main(int argc, char **argv)
/* this enables the fail-on-alloc-number-N functionality */
env = curl_getenv("CURL_MEMLIMIT");
if(env) {
curl_memlimit(atoi(env));
char *endptr;
long num = strtol(env, &endptr, 10);
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
curl_memlimit(num);
curl_free(env);
}
#endif

View file

@ -28,7 +28,7 @@ int test(char *URL)
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_VERBOSE, 1L);

View file

@ -57,7 +57,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set port number */
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) );
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
/* specify target */
test_setopt(curl,CURLOPT_URL, URL);

View file

@ -531,8 +531,8 @@ static int ProcessRequest(struct httprequest *req)
/* if the host name starts with test, the port number used in the
CONNECT line will be used as test number! */
char *portp = strchr(doc, ':');
if(portp)
req->testno = atoi(portp+1);
if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1)))
req->testno = strtol(portp+1, NULL, 10);
else
req->testno = DOCNUMBER_CONNECT;
}

View file

@ -467,8 +467,8 @@ static int ProcessRequest(struct httprequest *req)
/* if the host name starts with test, the port number used in the
CONNECT line will be used as test number! */
char *portp = strchr(doc, ':');
if(portp)
req->testno = atoi(portp+1);
if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1)))
req->testno = strtol(portp+1, NULL, 10);
else
req->testno = DOCNUMBER_CONNECT;
}