Add isc_buffer_trycompact() function needed for StreamDNS
Add isc_buffer_trycompact() that's an optimization; it will compact the buffer only when the remaining length is smaller than used length.
This commit is contained in:
@@ -265,6 +265,8 @@ isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length);
|
||||
*
|
||||
*/
|
||||
|
||||
static inline void
|
||||
isc_buffer_trycompact(isc_buffer_t *b);
|
||||
static inline void
|
||||
isc_buffer_compact(isc_buffer_t *b);
|
||||
/*!<
|
||||
@@ -1043,6 +1045,13 @@ isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length) {
|
||||
b->length = length;
|
||||
}
|
||||
|
||||
static inline void
|
||||
isc_buffer_trycompact(isc_buffer_t *b) {
|
||||
if (isc_buffer_consumedlength(b) >= isc_buffer_remaininglength(b)) {
|
||||
isc_buffer_compact(b);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
isc_buffer_compact(isc_buffer_t *b) {
|
||||
unsigned int length;
|
||||
|
||||
Reference in New Issue
Block a user