digiKam
alloc_pool.h
Go to the documentation of this file.
1 /*
2  * H.265 video codec.
3  * Copyright (c) 2014 struktur AG, Dirk Farin <farin@struktur.de>
4  *
5  * Authors: Dirk Farin <farin@struktur.de>
6  *
7  * This file is part of libde265.
8  *
9  * libde265 is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation, either version 3 of
12  * the License, or (at your option) any later version.
13  *
14  * libde265 is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef ALLOC_POOL_H
24 #define ALLOC_POOL_H
25 
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 
30 #include <vector>
31 #include <cstddef>
32 #ifdef HAVE_STDINT_H
33 #include <stdint.h>
34 #endif
35 #ifdef HAVE_CSTDINT
36 #include <cstdint>
37 #endif
38 
39 
41 {
42  public:
43  alloc_pool(size_t objSize, int poolSize=1000, bool grow=true);
45 
46  void* new_obj(const size_t size);
47  void delete_obj(void*);
48  void purge();
49 
50  private:
51  size_t mObjSize;
52  int mPoolSize;
53  bool mGrow;
54 
55  std::vector<uint8_t*> m_memBlocks;
56  std::vector<void*> m_freeList;
57 
58  void add_memory_block();
59 };
60 
61 #endif
Definition: alloc_pool.h:41
alloc_pool(size_t objSize, int poolSize=1000, bool grow=true)
void delete_obj(void *)
void purge()
void * new_obj(const size_t size)