struct async_append * async_append_create(int fd) { struct async_append *ap; ap = xmalloc(sizeof *ap); ap->fd = fd; ap->aiocbs = xmalloc(MAX_CBS * sizeof *ap->aiocbs); ap->aiocb_head = ap->aiocb_tail = 0; ap->buffer = xmalloc(BUFFER_SIZE); byteq_init(&ap->byteq, ap->buffer, BUFFER_SIZE); return ap; }
/* Returns a new JSON-RPC stream that uses 'stream' for input and output. The * new jsonrpc object takes ownership of 'stream'. */ struct jsonrpc * jsonrpc_open(struct stream *stream) { struct jsonrpc *rpc; ovs_assert(stream != NULL); rpc = xzalloc(sizeof *rpc); rpc->name = xstrdup(stream_get_name(stream)); rpc->stream = stream; byteq_init(&rpc->input, rpc->input_buffer, sizeof rpc->input_buffer); list_init(&rpc->output); return rpc; }