Skip to content

Commit 56bb199

Browse files
addaleaxMylesBorins
authored andcommitted
deps: cherry-pick eb306f463e from nghttp2 upstream
Original commit message: lib: add nghttp2_rcbuf_is_static() Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf is statically allocated. This can be useful for language bindings that wish to avoid creating duplicate strings for these buffers; concretely, I am planning to use this in the Node HTTP/2 module that is being introduced. Ref: nghttp2/nghttp2@eb306f4 PR-URL: #14808 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent 4f49ae5 commit 56bb199

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

deps/nghttp2/lib/includes/nghttp2/nghttp2.h

+9
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,15 @@ NGHTTP2_EXTERN void nghttp2_rcbuf_decref(nghttp2_rcbuf *rcbuf);
469469
*/
470470
NGHTTP2_EXTERN nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf);
471471

472+
/**
473+
* @function
474+
*
475+
* Returns 1 if the underlying buffer is statically allocated,
476+
* and 0 otherwise. This can be useful for language bindings that wish to avoid
477+
* creating duplicate strings for these buffers.
478+
*/
479+
NGHTTP2_EXTERN int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf);
480+
472481
/**
473482
* @enum
474483
*

deps/nghttp2/lib/nghttp2_rcbuf.c

+4
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf) {
9696
nghttp2_vec res = {rcbuf->base, rcbuf->len};
9797
return res;
9898
}
99+
100+
int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf) {
101+
return rcbuf->ref == -1;
102+
}

0 commit comments

Comments
 (0)