]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/io.h
Merge branch 'master' of ozlabs.org:ccan
[ccan] / ccan / io / io.h
index b5ffdd243bfd8a1710e551741261bb9159923cff..6248fec02c2e5c5ae3d42e65d80eb8483af1d5aa 100644 (file)
@@ -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 */