int test(char *URL)
{
int res = 0;
- CURL *curl[NUM_HANDLES];
+ CURL *curl[NUM_HANDLES] = {0};
int running;
CURLM *m = NULL;
int i;
char target_url[256];
char dnsentry[256];
- struct curl_slist *slist = NULL;
+ struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
for(i=0; i < NUM_HANDLES; i++) {
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
printf("%s\n", dnsentry);
- slist = curl_slist_append(slist, dnsentry);
+ slist2 = curl_slist_append(slist, dnsentry);
+ if(!slist2) {
+ fprintf(stderr, "curl_slist_append() failed\n");
+ goto test_cleanup;
+ }
+ slist = slist2;
}
- for(i=0; i < NUM_HANDLES; i++)
- curl[i] = NULL;
-
start_test_timing();
global_init(CURL_GLOBAL_ALL);
int test(char *URL)
{
- CURL *curl;
- CURLM *mcurl;
+ int res = 0;
+ CURL *curl = NULL;
+ CURLM *mcurl = NULL;
int still_running = 1;
struct timeval mp_start;
struct curl_slist* rcpt_list = NULL;
curl_global_init(CURL_GLOBAL_DEFAULT);
- curl = curl_easy_init();
- if(!curl)
- return 1;
+ easy_init(curl);
- mcurl = curl_multi_init();
- if(!mcurl)
- return 2;
+ multi_init(mcurl);
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
/* more addresses can be added here
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_multi_add_handle(mcurl, curl);
+ multi_add_handle(mcurl, curl);
mp_start = tvnow();
}
}
+test_cleanup:
+
curl_slist_free_all(rcpt_list);
curl_multi_remove_handle(mcurl, curl);
curl_multi_cleanup(mcurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
- return 0;
+
+ return res;
}
int i;
char target_url[256];
char dnsentry[256];
- struct curl_slist *slist = NULL;
+ struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
for(i=0; i < NUM_URLS; i++) {
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
printf("%s\n", dnsentry);
- slist = curl_slist_append(slist, dnsentry);
+ slist2 = curl_slist_append(slist, dnsentry);
+ if(!slist2) {
+ fprintf(stderr, "curl_slist_append() failed\n");
+ goto test_cleanup;
+ }
+ slist = slist2;
}
start_test_timing();