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

Function writev

dpdk/lib/pcapng/rte_pcapng.c:64–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62};
63
64static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
65{
66 size_t bytes = 0;
67 uint8_t *ptr;
68 void *tmp_buf;
69 ssize_t ret;
70 int i;
71
72 for (i = 0; i < iovcnt; i++)
73 bytes += iov[i].iov_len;
74
75 if (unlikely(bytes == 0))
76 return 0;
77
78 tmp_buf = malloc(bytes);
79 if (unlikely(tmp_buf == NULL)) {
80 errno = ENOMEM;
81 return -1;
82 }
83
84 ptr = tmp_buf;
85 for (i = 0; i < iovcnt; i++) {
86 rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
87 ptr += iov[i].iov_len;
88 }
89
90 ret = write(fd, tmp_buf, bytes);
91 free(tmp_buf);
92 return ret;
93}
94
95#define IF_NAMESIZE 16
96/* compatibility wrapper because name is optional */

Callers 5

rte_pcapng_write_packetsFunction · 0.70
xo_send_syslogFunction · 0.50
zed_conf_write_stateFunction · 0.50
rte_dump_stackFunction · 0.50
tap_write_mbufsFunction · 0.50

Calls 4

mallocFunction · 0.85
rte_memcpyFunction · 0.50
writeFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected