From 165ada34a3525876890c644a61efd4b17cb4adc0 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 26 Aug 2021 16:38:00 -0700 Subject: [PATCH] docs(ffi): note that hyper_buf_copy can return NULL on error --- capi/include/hyper.h | 2 ++ src/ffi/body.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/capi/include/hyper.h b/capi/include/hyper.h index 64e28bf8..2245d6a4 100644 --- a/capi/include/hyper.h +++ b/capi/include/hyper.h @@ -299,6 +299,8 @@ void hyper_body_set_data_func(struct hyper_body *body, hyper_body_data_callback This makes an owned copy of the bytes, so the `buf` argument can be freed or changed afterwards. + + This returns `NULL` if allocating a new buffer fails. */ struct hyper_buf *hyper_buf_copy(const uint8_t *buf, size_t len); diff --git a/src/ffi/body.rs b/src/ffi/body.rs index 932200b5..39ba5bef 100644 --- a/src/ffi/body.rs +++ b/src/ffi/body.rs @@ -185,6 +185,8 @@ ffi_fn! { /// /// This makes an owned copy of the bytes, so the `buf` argument can be /// freed or changed afterwards. + /// + /// This returns `NULL` if allocating a new buffer fails. fn hyper_buf_copy(buf: *const u8, len: size_t) -> *mut hyper_buf { let slice = unsafe { std::slice::from_raw_parts(buf, len)