From e392a1af4db67eb6dc5201eeb4e5fe89f35d5508 Mon Sep 17 00:00:00 2001 From: Andrius Bentkus Date: Mon, 23 Jun 2014 17:13:21 +0300 Subject: [PATCH] header: introduce `uv_loop_size()` We add a function called uv_loop_size which returns the size of the loop. It is an additional function which complements `uv_handle_size` and` uv_req_size` in order to provide full FFI support. Signed-off-by: Fedor Indutny --- include/uv.h | 5 +++++ src/uv-common.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/uv.h b/include/uv.h index 2cda9902..ba809864 100644 --- a/include/uv.h +++ b/include/uv.h @@ -288,6 +288,11 @@ UV_EXTERN uv_loop_t* uv_loop_new(void); */ UV_EXTERN void uv_loop_delete(uv_loop_t*); +/* + * Returns size of the loop struct, useful for dynamic lookup with FFI + */ +UV_EXTERN size_t uv_loop_size(void); + /* * This function runs the event loop. It will act differently depending on the * specified mode: diff --git a/src/uv-common.c b/src/uv-common.c index 97892068..d9553c91 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -67,6 +67,11 @@ size_t uv_req_size(uv_req_type type) { #undef XX +size_t uv_loop_size(void) { + return sizeof(uv_loop_t); +} + + uv_buf_t uv_buf_init(char* base, unsigned int len) { uv_buf_t buf; buf.base = base;