1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

simplied the creation of new urls

This commit is contained in:
Daniel Stenberg 2004-05-06 13:29:04 +00:00
parent 0aa7d11cc9
commit 84b52e92f4

View File

@ -3,6 +3,8 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <mprintf.h>
const char *HOSTHEADER = "Host: www.host.foo.com"; const char *HOSTHEADER = "Host: www.host.foo.com";
const char *JAR = "log/jar506"; const char *JAR = "log/jar506";
#define THREADS 2 #define THREADS 2
@ -120,15 +122,7 @@ void *fire(void *ptr)
/* build request url */ /* build request url */
char *suburl(char *base, int i) char *suburl(char *base, int i)
{ {
size_t len = strlen(base); return curl_maprintf("%s000%c", base, 48+i);
char *url = (char *)malloc(len+5);
if (!url) {
abort();
}
strcpy(url, base);
strcat(url, "0000");
url[len+3] = 48+i;
return url;
} }
@ -168,14 +162,14 @@ int test(char *URL)
for (i=1; i<=THREADS; i++ ) { for (i=1; i<=THREADS; i++ ) {
/* set thread data */ /* set thread data */
tdata.url = suburl( URL, i ); /* must be freed */ tdata.url = suburl( URL, i ); /* must be curl_free()d */
tdata.share = share; tdata.share = share;
/* simulate thread, direct call of "thread" function */ /* simulate thread, direct call of "thread" function */
printf( "*** run %d\n",i ); printf( "*** run %d\n",i );
fire( &tdata ); fire( &tdata );
free( tdata.url ); curl_free( tdata.url );
} }
@ -211,8 +205,8 @@ int test(char *URL)
printf( "CLEANUP\n" ); printf( "CLEANUP\n" );
curl_easy_cleanup( curl ); curl_easy_cleanup( curl );
curl_slist_free_all( headers ); curl_slist_free_all( headers );
free(url);
curl_free(url);
/* free share */ /* free share */
printf( "SHARE_CLEANUP\n" ); printf( "SHARE_CLEANUP\n" );