void add_to_interval_list(struct iperf_stream_result *rp, struct iperf_interval_results *new)
{
- static struct iperf_interval_results irp;
-
- memcpy(&irp, new, sizeof(struct iperf_interval_results));
- TAILQ_INSERT_HEAD(&rp->interval_results, &irp, irlistentries);
+ memcpy(rp->interval_results, new, sizeof(struct iperf_interval_results));
}
/************************************************************/
temp.bytes_transferred = test->sender ? rp->bytes_sent_this_interval : rp->bytes_received_this_interval;
- irp = TAILQ_LAST(&rp->interval_results, irlisthead);
+ irp = rp->interval_results;
/* result->end_time contains timestamp of previous interval */
if (irp != NULL) { /* not the 1st interval */
memcpy(&temp.interval_start_time, &rp->end_time, sizeof(struct timeval));
SLIST_FOREACH(sp, &test->streams, streams) {
print_interval_results(test, sp, json_interval_streams);
/* sum up all streams */
- irp = TAILQ_LAST(&sp->result->interval_results, irlisthead);
+ irp = sp->result->interval_results;
if (irp == NULL) {
iperf_err(test, "iperf_print_intermediate error: interval_results is NULL");
return;
sp = SLIST_FIRST(&test->streams); /* reset back to 1st stream */
/* Only do this of course if there was a first stream */
if (sp) {
- irp = TAILQ_LAST(&sp->result->interval_results, irlisthead); /* use 1st stream for timing info */
+ irp = sp->result->interval_results;
unit_snprintf(ubuf, UNIT_LEN, (double)bytes, 'A');
bandwidth = (double)bytes / (double)irp->interval_duration;
double bandwidth;
double lost_percent;
- irp = TAILQ_LAST(&sp->result->interval_results, irlisthead); /* get last entry in linked list */
+ irp = sp->result->interval_results; /* get last entry in linked list */
if (irp == NULL) {
iperf_err(test, "print_interval_results error: interval_results is NULL");
return;
#else
free(sp->buffer);
#endif
+ free(sp->result->interval_results);
free(sp->result);
if (sp->send_timer != NULL) {
tmr_cancel(sp->send_timer);
}
memset(sp->result, 0, sizeof(struct iperf_stream_result));
- TAILQ_INIT(&sp->result->interval_results);
+
+ sp->result->interval_results = malloc(sizeof(struct iperf_interval_results));
+
+ if (!sp->result->interval_results) {
+ free(sp->result);
+ free(sp);
+ i_errno = IECREATESTREAM;
+ return NULL;
+ }
#ifdef HAVE_FILESYSTEM
/* Create and randomize the buffer */
sp->buffer_fd = mkstemp(template);
if (sp->buffer_fd == -1) {
i_errno = IECREATESTREAM;
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
return NULL;
}
if (unlink(template) < 0) {
i_errno = IECREATESTREAM;
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
return NULL;
}
if (ftruncate(sp->buffer_fd, test->settings->blksize) < 0) {
i_errno = IECREATESTREAM;
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
return NULL;
sp->buffer = (char *)mmap(NULL, test->settings->blksize, PROT_READ | PROT_WRITE, MAP_PRIVATE, sp->buffer_fd, 0);
if (sp->buffer == MAP_FAILED) {
i_errno = IECREATESTREAM;
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
return NULL;
sp->buffer = (char *)malloc(test->settings->blksize);
if (sp->buffer == NULL) {
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
i_errno = IECREATESTREAM;
#else
free(sp->buffer);
#endif
+ free(sp->result->interval_results);
free(sp->result);
free(sp);
return NULL;