Ardour  9.0-pre0-582-g084a23a80d
tlsf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef _tlsf_h_
19 #define _tlsf_h_
20 
21 #include <string>
22 
23 #ifndef LIBPBD_API
24 #include "pbd/libpbd_visibility.h"
25 #endif
26 
27 namespace PBD {
28 
30 {
31 public:
32  TLSF (std::string name, size_t bytes);
33  ~TLSF ();
34 
35  void set_name (const std::string& n) { _name = n; }
36 
37  static void * lalloc (void* pool, void* ptr, size_t /* oldsize*/, size_t newsize) {
38  return static_cast<TLSF*>(pool)->_realloc (ptr, newsize);
39  }
40 
41  void* malloc (size_t size) { return _malloc (size); }
42 
43  void* realloc (void *ptr, size_t newsize) { return _realloc (ptr, newsize); }
44 
45  void free (void* ptr) { _free (ptr); }
46 
47  size_t get_used_size () const;
48  size_t get_max_size () const;
49 
50 private:
51  std::string _name;
52  char*_mp;
53 
54  void* _malloc (size_t);
55  void* _realloc (void *, size_t);
56  void _free (void *);
57 };
58 
59 } /* namespace */
60 #endif // _reallocpool_h_
Definition: tlsf.h:30
TLSF(std::string name, size_t bytes)
size_t get_max_size() const
void * _realloc(void *, size_t)
void * _malloc(size_t)
void _free(void *)
char * _mp
Definition: tlsf.h:52
static void * lalloc(void *pool, void *ptr, size_t, size_t newsize)
Definition: tlsf.h:37
void * realloc(void *ptr, size_t newsize)
Definition: tlsf.h:43
std::string _name
Definition: tlsf.h:51
void * malloc(size_t size)
Definition: tlsf.h:41
size_t get_used_size() const
void set_name(const std::string &n)
Definition: tlsf.h:35
void free(void *ptr)
Definition: tlsf.h:45
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBPBD_API
Definition: axis_view.h:42
minimum disk read bytes