X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fio%2Fio.h;h=6248fec02c2e5c5ae3d42e65d80eb8483af1d5aa;hp=b5ffdd243bfd8a1710e551741261bb9159923cff;hb=96a1ebd3354ef6250e94b509b4e0c0f1ea7e67bb;hpb=cece098555b7138082373d5c0ddfa8074da18dda;ds=sidebyside diff --git a/ccan/io/io.h b/ccan/io/io.h index b5ffdd24..6248fec0 100644 --- a/ccan/io/io.h +++ b/ccan/io/io.h @@ -490,4 +490,25 @@ struct io_plan io_close_cb(struct io_conn *, void *unused); * io_loop(); */ void *io_loop(void); + +/** + * io_conn_fd - get the fd from a connection. + * @conn: the connection. + * + * Sometimes useful, eg for getsockname(). + */ +int io_conn_fd(const struct io_conn *conn); + +/** + * io_set_alloc - set alloc/realloc/free function for io to use. + * @allocfn: allocator function + * @reallocfn: reallocator function, ptr may be NULL, size never 0. + * @freefn: free function + * + * By default io uses malloc/realloc/free, and returns NULL if they fail. + * You can set your own variants here. + */ +void io_set_alloc(void *(*allocfn)(size_t size), + void *(*reallocfn)(void *ptr, size_t size), + void (*freefn)(void *ptr)); #endif /* CCAN_IO_H */