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

Function NgAllocRecvMsg

tools/libnetgraph/msg.c:334–352  ·  view source on GitHub ↗

* Identical to NgRecvMsg() except buffer is dynamically allocated. */

Source from the content-addressed store, hash-verified

332 * Identical to NgRecvMsg() except buffer is dynamically allocated.
333 */
334int
335NgAllocRecvMsg(int cs, struct ng_mesg **rep, char *path)
336{
337 int len;
338#ifndef FSTACK
339 socklen_t optlen;
340
341 optlen = sizeof(len);
342 if (getsockopt(cs, SOL_SOCKET, SO_RCVBUF, &len, &optlen) == -1 ||
343#else
344 len = NGCTL_DEFAULT_RCVBUF;
345 if (
346#endif
347 (*rep = malloc(len)) == NULL)
348 return (-1);
349 if ((len = NgRecvMsg(cs, *rep, len, path)) < 0)
350 free(*rep);
351 return (len);
352}
353
354/*
355 * Receive a control message and convert the arguments to ASCII

Callers 6

NgSendAsciiMsgFunction · 0.85
ShowCmdFunction · 0.85
MsgReadFunction · 0.85
TypesCmdFunction · 0.85
DotCmdFunction · 0.85
ListCmdFunction · 0.85

Calls 4

getsockoptFunction · 0.85
mallocFunction · 0.85
NgRecvMsgFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected