docs(ffi): note that hyper_buf_copy can return NULL on error

This commit is contained in:
Sean McArthur
2021-08-26 16:38:00 -07:00
parent f46b175bf7
commit 165ada34a3
2 changed files with 4 additions and 0 deletions

View File

@@ -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 This makes an owned copy of the bytes, so the `buf` argument can be
freed or changed afterwards. 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); struct hyper_buf *hyper_buf_copy(const uint8_t *buf, size_t len);

View File

@@ -185,6 +185,8 @@ ffi_fn! {
/// ///
/// This makes an owned copy of the bytes, so the `buf` argument can be /// This makes an owned copy of the bytes, so the `buf` argument can be
/// freed or changed afterwards. /// 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 { fn hyper_buf_copy(buf: *const u8, len: size_t) -> *mut hyper_buf {
let slice = unsafe { let slice = unsafe {
std::slice::from_raw_parts(buf, len) std::slice::from_raw_parts(buf, len)