Skip to content

Commit

Permalink
deps: cherry-pick eb306f463e from nghttp2 upstream
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax authored and MylesBorins committed Sep 12, 2017
1 parent 4f49ae5 commit 56bb199
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions deps/nghttp2/lib/includes/nghttp2/nghttp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 4 additions & 0 deletions deps/nghttp2/lib/nghttp2_rcbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 56bb199

Please sign in to comment.