xref: /haiku/src/kits/package/hpkg/BlockBufferPool.cpp (revision 71452e98334eaac603bf542d159e24788a46bebb)
1 /*
2  * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <package/hpkg/BlockBufferPool.h>
8 
9 #include <new>
10 
11 #include <package/hpkg/BlockBufferPoolImpl.h>
12 
13 
14 namespace BPackageKit {
15 
16 namespace BHPKG {
17 
18 
19 BBlockBufferPool::BBlockBufferPool(size_t blockSize, uint32 maxCachedBlocks)
20 	:
21 	fImpl(new (std::nothrow) BlockBufferPoolImpl(blockSize, maxCachedBlocks,
22 		this))
23 {
24 }
25 
26 
27 BBlockBufferPool::~BBlockBufferPool()
28 {
29 	delete fImpl;
30 }
31 
32 
33 status_t
34 BBlockBufferPool::Init()
35 {
36 	if (fImpl == NULL)
37 		return B_NO_MEMORY;
38 
39 	return fImpl->Init();
40 }
41 
42 
43 PoolBuffer*
44 BBlockBufferPool::GetBuffer(size_t size, PoolBuffer** owner,
45 	bool* _newBuffer)
46 {
47 	if (fImpl == NULL)
48 		return NULL;
49 
50 	return fImpl->GetBuffer(size, owner, _newBuffer);
51 }
52 
53 
54 void
55 BBlockBufferPool::PutBufferAndCache(PoolBuffer** owner)
56 {
57 	if (fImpl != NULL)
58 		fImpl->PutBufferAndCache(owner);
59 }
60 
61 
62 void
63 BBlockBufferPool::PutBuffer(PoolBuffer** owner)
64 {
65 	if (fImpl != NULL)
66 		fImpl->PutBuffer(owner);
67 }
68 
69 
70 }	// namespace BHPKG
71 
72 }	// namespace BPackageKit
73