From: Daniel Stenberg Date: Thu, 6 May 2004 13:29:04 +0000 (+0000) Subject: simplied the creation of new urls X-Git-Tag: upstream/7.37.1~12763 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84b52e92f4b1394851af28eeb15fca6beac56246;p=platform%2Fupstream%2Fcurl.git simplied the creation of new urls --- diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 943d9a9..22f5d06 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -3,6 +3,8 @@ #include #include +#include + const char *HOSTHEADER = "Host: www.host.foo.com"; const char *JAR = "log/jar506"; #define THREADS 2 @@ -120,15 +122,7 @@ void *fire(void *ptr) /* build request url */ char *suburl(char *base, int i) { - size_t len = strlen(base); - char *url = (char *)malloc(len+5); - if (!url) { - abort(); - } - strcpy(url, base); - strcat(url, "0000"); - url[len+3] = 48+i; - return url; + return curl_maprintf("%s000%c", base, 48+i); } @@ -168,14 +162,14 @@ int test(char *URL) for (i=1; i<=THREADS; i++ ) { /* set thread data */ - tdata.url = suburl( URL, i ); /* must be freed */ + tdata.url = suburl( URL, i ); /* must be curl_free()d */ tdata.share = share; /* simulate thread, direct call of "thread" function */ printf( "*** run %d\n",i ); fire( &tdata ); - free( tdata.url ); + curl_free( tdata.url ); } @@ -211,8 +205,8 @@ int test(char *URL) printf( "CLEANUP\n" ); curl_easy_cleanup( curl ); curl_slist_free_all( headers ); - free(url); - + + curl_free(url); /* free share */ printf( "SHARE_CLEANUP\n" );