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.
This commit is contained in:
parent
788835c5fd
commit
eb306f463e
|
@ -49,6 +49,7 @@ set(APIDOCS
|
||||||
nghttp2_rcbuf_decref.rst
|
nghttp2_rcbuf_decref.rst
|
||||||
nghttp2_rcbuf_get_buf.rst
|
nghttp2_rcbuf_get_buf.rst
|
||||||
nghttp2_rcbuf_incref.rst
|
nghttp2_rcbuf_incref.rst
|
||||||
|
nghttp2_rcbuf_is_static.rst
|
||||||
nghttp2_select_next_protocol.rst
|
nghttp2_select_next_protocol.rst
|
||||||
nghttp2_session_callbacks_del.rst
|
nghttp2_session_callbacks_del.rst
|
||||||
nghttp2_session_callbacks_new.rst
|
nghttp2_session_callbacks_new.rst
|
||||||
|
|
|
@ -74,6 +74,7 @@ APIDOCS= \
|
||||||
nghttp2_rcbuf_decref.rst \
|
nghttp2_rcbuf_decref.rst \
|
||||||
nghttp2_rcbuf_get_buf.rst \
|
nghttp2_rcbuf_get_buf.rst \
|
||||||
nghttp2_rcbuf_incref.rst \
|
nghttp2_rcbuf_incref.rst \
|
||||||
|
nghttp2_rcbuf_is_static.rst \
|
||||||
nghttp2_select_next_protocol.rst \
|
nghttp2_select_next_protocol.rst \
|
||||||
nghttp2_session_callbacks_del.rst \
|
nghttp2_session_callbacks_del.rst \
|
||||||
nghttp2_session_callbacks_new.rst \
|
nghttp2_session_callbacks_new.rst \
|
||||||
|
|
|
@ -469,6 +469,15 @@ NGHTTP2_EXTERN void nghttp2_rcbuf_decref(nghttp2_rcbuf *rcbuf);
|
||||||
*/
|
*/
|
||||||
NGHTTP2_EXTERN nghttp2_vec nghttp2_rcbuf_get_buf(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
|
* @enum
|
||||||
*
|
*
|
||||||
|
|
|
@ -96,3 +96,7 @@ nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf) {
|
||||||
nghttp2_vec res = {rcbuf->base, rcbuf->len};
|
nghttp2_vec res = {rcbuf->base, rcbuf->len};
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf) {
|
||||||
|
return rcbuf->ref == -1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue