From: Tudor Bosman Date: Wed, 13 Jun 2012 23:52:38 +0000 (-0700) Subject: Add an allocate() member function on IOBufQueue X-Git-Tag: v0.22.0~1260 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=62072424464bf9831aa899f23484d7b8c54daac6;p=folly.git Add an allocate() member function on IOBufQueue Summary: Function is documented in the header. Reviewed By: soren@fb.com FB internal diff: D494315 --- diff --git a/folly/experimental/io/IOBufQueue.h b/folly/experimental/io/IOBufQueue.h index 7c25c621..283cd3ac 100644 --- a/folly/experimental/io/IOBufQueue.h +++ b/folly/experimental/io/IOBufQueue.h @@ -114,6 +114,16 @@ class IOBufQueue { */ void postallocate(uint32_t n); + /** + * Obtain a writable block of n contiguous bytes, allocating more space + * if necessary, and mark it as used. The caller can fill it later. + */ + void* allocate(uint32_t n) { + void* p = preallocate(n, n).first; + postallocate(n); + return p; + } + /** * Split off the first n bytes of the queue into a separate IOBuf chain, * and transfer ownership of the new chain to the caller. The IOBufQueue