diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-05-27 21:40:29 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-05-27 21:40:29 -0400 |
commit | 3523bbda22a89eb0e64cd08958efa6cafd710c09 (patch) | |
tree | d57ae82dab951f40cf30a051ac02ab7a79c3b440 /example/src/middle.c | |
parent | 9f6eff69114a493047ffdf1bb6f0e3c86b2119aa (diff) | |
download | uv_link_t-3523bbda22a89eb0e64cd08958efa6cafd710c09.tar.gz |
src: simplify uv_link_close
Diffstat (limited to 'example/src/middle.c')
-rw-r--r-- | example/src/middle.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/example/src/middle.c b/example/src/middle.c index 447a341..6bd4e85 100644 --- a/example/src/middle.c +++ b/example/src/middle.c @@ -14,6 +14,12 @@ static int read_stop_impl(uv_link_t* link) { } +static void close_impl(uv_link_t* link, uv_link_t* source, + uv_link_close_cb cb) { + cb(source); +} + + static void alloc_cb_override(uv_link_t* link, size_t suggested_size, uv_buf_t* buf) { @@ -35,7 +41,9 @@ static void read_cb_override(uv_link_t* link, else res = "go away"; } else { - res = "error"; + free(buf->base); + uv_link_propagate_read_cb(link, nread, NULL); + return; } free(buf->base); @@ -51,6 +59,7 @@ static void read_cb_override(uv_link_t* link, uv_link_methods_t middle_methods = { .read_start = read_start_impl, .read_stop = read_stop_impl, + .close = close_impl, /* Other doesn't matter in this example */ .alloc_cb_override = alloc_cb_override, |