* Identical to NgRecvMsg() except buffer is dynamically allocated. */
| 332 | * Identical to NgRecvMsg() except buffer is dynamically allocated. |
| 333 | */ |
| 334 | int |
| 335 | NgAllocRecvMsg(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 |