CVC3  2.4.1
memory_manager_malloc.h
Go to the documentation of this file.
1 /*****************************************************************************/
2 /*!
3  * \file memory_manager_malloc.h
4  *
5  * Author: Sergey Berezin
6  *
7  * Created: Tue Apr 19 14:30:36 2005
8  *
9  * <hr>
10  *
11  * License to use, copy, modify, sell and/or distribute this software
12  * and its documentation for any purpose is hereby granted without
13  * royalty, subject to the terms and conditions defined in the \ref
14  * LICENSE file provided with this distribution.
15  *
16  * <hr>
17  *
18  * Class MemoryManagerMalloc: default implementation of MemoryManager
19  * using malloc().
20  *
21  * Typical use of this class is to create
22  * MemoryManager* mm = new MemoryManager(sizeof(YourClass));
23  * where YourClass has operators new and delete redefined:
24  * void* YourClass::operator new(size_t, MemoryManager* mm)
25  * { return mm->newData(); }
26  * void YourClass::delete(void*) { } // do not deallocate memory here
27  * Then, create objects with obj = new(mm) YourClass(), and destroy them with
28  * delete obj; mm->deleteData(obj);
29  */
30 /*****************************************************************************/
31 
32 #ifndef _cvc3__memory_manager_malloc_h
33 #define _cvc3__memory_manager_malloc_h
34 
35 #include "memory_manager.h"
36 
37 namespace CVC3 {
38 
40  public:
41  // Constructor
43  // Destructor
45 
46  void* newData(size_t size) {
47  return malloc(size);
48  }
49 
50  void deleteData(void* d) {
51  free(d);
52  }
53 }; // end of class MemoryManager
54 
55 }
56 
57 #endif