CUBRID Engine  latest
mallocheap.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /*
4 
5  Heap Layers: An Extensible Memory Allocation Infrastructure
6 
7  Copyright (C) 2000-2020 by Emery Berger
8  http://www.emeryberger.com
9  emery@cs.umass.edu
10 
11  Heap Layers is distributed under the terms of the Apache 2.0 license.
12 
13  You may obtain a copy of the License at
14  http://www.apache.org/licenses/LICENSE-2.0
15 
16 */
17 
18 #ifndef HL_MALLOCHEAP_H
19 #define HL_MALLOCHEAP_H
20 
21 #include <cstdlib>
22 
23 #if defined(__SVR4)
24 extern "C" size_t malloc_usable_size (void *);
25 #elif defined(__APPLE__)
26 #include <malloc/malloc.h>
27 #elif defined(__linux__)
28 #include <malloc.h>
29 #else
30 extern "C" size_t malloc_usable_size (void *) throw ();
31 #endif
32 
38 #include "wrappers/mallocinfo.h"
39 
40 
41 namespace HL {
42 
43  class MallocHeap {
44  public:
45 
47 
48  inline void * malloc (size_t sz) {
49  return ::malloc (sz);
50  }
51 
52  inline void free (void * ptr) {
53  ::free (ptr);
54  }
55 
56 #if defined(_MSC_VER)
57  inline size_t getSize (void * ptr) {
58  return ::_msize (ptr);
59  }
60 #elif defined(__APPLE__)
61  inline size_t getSize (void * ptr) {
62  return ::malloc_size (ptr);
63  }
64 #elif defined(__GNUC__) && !defined(__SVR4)
65  inline size_t getSize (void * ptr) {
67  }
68 #endif
69 
70  };
71 
72 }
73 
74 #endif
size_t malloc_usable_size(void *)
Definition: heaplayers.h:34
void free(void *ptr)
Definition: mallocheap.h:52
void * malloc(size_t sz)
Definition: mallocheap.h:48