Permalink
Browse files

Add an allocate() member function on IOBufQueue

Summary: Function is documented in the header.

Reviewed By: soren@fb.com

FB internal diff: D494315
  • Loading branch information...
1 parent 8108795 commit 62072424464bf9831aa899f23484d7b8c54daac6 @tudor tudor committed with jdelong Jun 13, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 folly/experimental/io/IOBufQueue.h
@@ -115,6 +115,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
* retains ownership of everything after the split point.

0 comments on commit 6207242

Please sign in to comment.