3 #include <winpr/stream.h>
4 #include <winpr/collections.h>
6 int TestBufferPool(
int argc,
char* argv[])
9 SSIZE_T BufferSize = 0;
10 wBufferPool* pool = NULL;
11 BYTE* Buffers[10] = { 0 };
12 int DefaultSize = 1234;
17 pool = BufferPool_New(TRUE, -1, 16);
21 Buffers[0] = BufferPool_Take(pool, DefaultSize);
22 Buffers[1] = BufferPool_Take(pool, DefaultSize);
23 Buffers[2] = BufferPool_Take(pool, 2048);
24 if (!Buffers[0] || !Buffers[1] || !Buffers[2])
27 BufferSize = BufferPool_GetBufferSize(pool, Buffers[0]);
29 if (BufferSize != DefaultSize)
31 printf(
"BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32
"\n", BufferSize,
36 BufferSize = BufferPool_GetBufferSize(pool, Buffers[1]);
38 if (BufferSize != DefaultSize)
40 printf(
"BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32
"\n", BufferSize,
45 BufferSize = BufferPool_GetBufferSize(pool, Buffers[2]);
47 if (BufferSize != 2048)
49 printf(
"BufferPool_GetBufferSize failure: Actual: %d Expected: 2048\n", BufferSize);
53 BufferPool_Return(pool, Buffers[1]);
55 PoolSize = BufferPool_GetPoolSize(pool);
59 printf(
"BufferPool_GetPoolSize failure: Actual: %" PRIu32
" Expected: 2\n", PoolSize);
63 BufferPool_Clear(pool);
65 BufferPool_Free(pool);