MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_new_test

Function iperf_new_test

src/iperf_api.c:3176–3226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3174/**************************************************************************/
3175
3176struct iperf_test *
3177iperf_new_test()
3178{
3179 struct iperf_test *test;
3180 int rc;
3181
3182 test = (struct iperf_test *) malloc(sizeof(struct iperf_test));
3183 if (!test) {
3184 i_errno = IENEWTEST;
3185 return NULL;
3186 }
3187 /* initialize everything to zero */
3188 memset(test, 0, sizeof(struct iperf_test));
3189
3190 /* Initialize mutex for printing output */
3191 pthread_mutexattr_t mutexattr;
3192 pthread_mutexattr_init(&mutexattr);
3193 rc = pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK);
3194 if (rc != 0) {
3195 errno = rc;
3196 perror("iperf_new_test: pthread_mutexattr_settype");
3197 }
3198
3199 if (pthread_mutex_init(&(test->print_mutex), &mutexattr) != 0) {
3200 perror("iperf_new_test: pthread_mutex_init");
3201 }
3202
3203 pthread_mutexattr_destroy(&mutexattr);
3204
3205 test->settings = (struct iperf_settings *) malloc(sizeof(struct iperf_settings));
3206 if (!test->settings) {
3207 free(test);
3208 i_errno = IENEWTEST;
3209 return NULL;
3210 }
3211 memset(test->settings, 0, sizeof(struct iperf_settings));
3212
3213 test->bitrate_limit_intervals_traffic_bytes = (iperf_size_t *) malloc(sizeof(iperf_size_t) * MAX_INTERVAL);
3214 if (!test->bitrate_limit_intervals_traffic_bytes) {
3215 free(test->settings);
3216 free(test);
3217 i_errno = IENEWTEST;
3218 return NULL;
3219 }
3220 memset(test->bitrate_limit_intervals_traffic_bytes, 0, sizeof(iperf_size_t) * MAX_INTERVAL);
3221
3222 /* By default all output goes to stdout */
3223 test->outfile = stdout;
3224
3225 return test;
3226}
3227
3228/**************************************************************************/
3229

Callers 4

mainFunction · 0.85
main.cFile · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…