MCPcopy Create free account
hub / github.com/F-Stack/f-stack / populate_socket_mem_param

Function populate_socket_mem_param

dpdk/app/test/test_eal_flags.c:1446–1472  ·  view source on GitHub ↗

This function writes in passed buf pointer a valid --socket-mem= option * for num_sockets then concatenates the provided suffix string. * * Example for num_sockets 4, mem "2", suffix "plop" * --socket-mem=2,2,2,2plop */

Source from the content-addressed store, hash-verified

1444 * --socket-mem=2,2,2,2plop
1445 */
1446static void
1447populate_socket_mem_param(int num_sockets, const char *mem,
1448 const char *suffix, char *buf, size_t buf_size)
1449{
1450 unsigned int offset = 0;
1451 int written;
1452 int i;
1453
1454 written = snprintf(&buf[offset], buf_size - offset, "--socket-mem=");
1455 if (written < 0 || written + offset >= buf_size)
1456 return;
1457 offset += written;
1458
1459 for (i = 0; i < num_sockets - 1; i++) {
1460 written = snprintf(&buf[offset], buf_size - offset,
1461 "%s,", mem);
1462 if (written < 0 || written + offset >= buf_size)
1463 return;
1464 offset += written;
1465 }
1466
1467 written = snprintf(&buf[offset], buf_size - offset, "%s%s", mem,
1468 suffix);
1469 if (written < 0 || written + offset >= buf_size)
1470 return;
1471 offset += written;
1472}
1473
1474/*
1475 * Tests for correct handling of -m and --socket-mem flags

Callers 1

test_memory_flagsFunction · 0.85

Calls 1

snprintfFunction · 0.85

Tested by

no test coverage detected