mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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: eb306f463e
PR-URL: https://github.com/nodejs/node/pull/14808
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
9
deps/nghttp2/lib/includes/nghttp2/nghttp2.h
vendored
9
deps/nghttp2/lib/includes/nghttp2/nghttp2.h
vendored
@@ -469,6 +469,15 @@ NGHTTP2_EXTERN void nghttp2_rcbuf_decref(nghttp2_rcbuf *rcbuf);
|
||||
*/
|
||||
NGHTTP2_EXTERN nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns 1 if the underlying buffer is statically allocated,
|
||||
* and 0 otherwise. This can be useful for language bindings that wish to avoid
|
||||
* creating duplicate strings for these buffers.
|
||||
*/
|
||||
NGHTTP2_EXTERN int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf);
|
||||
|
||||
/**
|
||||
* @enum
|
||||
*
|
||||
|
||||
4
deps/nghttp2/lib/nghttp2_rcbuf.c
vendored
4
deps/nghttp2/lib/nghttp2_rcbuf.c
vendored
@@ -96,3 +96,7 @@ nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf) {
|
||||
nghttp2_vec res = {rcbuf->base, rcbuf->len};
|
||||
return res;
|
||||
}
|
||||
|
||||
int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf) {
|
||||
return rcbuf->ref == -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user