08.11.2014 Views

Memory Management - Poco

Memory Management - Poco

Memory Management - Poco

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

#include "<strong>Poco</strong>/<strong>Memory</strong>Pool.h"<br />

#include <br />

#include <br />

using <strong>Poco</strong>::<strong>Memory</strong>Pool;<br />

int main(int argc, char** argv)<br />

{<br />

<strong>Memory</strong>Pool pool(1024); // unlimited number of 1024 byte blocks<br />

// <strong>Memory</strong>Pool pool(1024, 4, 16); // at most 16 blocks; 4 preallocated<br />

char* buffer = reinterpret_cast(pool.get());<br />

std::cin.read(buffer, pool.blockSize());<br />

std::streamsize n = std::cin.gcount();<br />

std::string s(buffer, n);<br />

pool.release(buffer);<br />

std::cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!