luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Common.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef __COMMON_H__
23 #define __COMMON_H__
24 
25 // #define OVERRIDE_NEW to override the default implementation of new. Doing
26 // so will allow the heap analysis tool to figure out who called new.
27 #undef OVERRIDE_NEW
28 #ifdef OVERRIDE_NEW
29 
30 #include <new>
31 #include <cstring>
32 #include <cstdlib>
33 
34 #define COMMON_PRIVATE_INLINE inline __attribute__((always_inline))
35 COMMON_PRIVATE_INLINE void* operator new(size_t size) { return malloc(size); }
36 COMMON_PRIVATE_INLINE void* operator new(size_t size, const std::nothrow_t&) throw() { return malloc(size); }
37 COMMON_PRIVATE_INLINE void operator delete(void* p) { free(p); }
38 COMMON_PRIVATE_INLINE void operator delete(void* p, const std::nothrow_t&) throw() { free(p); }
39 COMMON_PRIVATE_INLINE void* operator new[](size_t size) { return malloc(size); }
40 COMMON_PRIVATE_INLINE void* operator new[](size_t size, const std::nothrow_t&) throw() { return malloc(size); }
41 COMMON_PRIVATE_INLINE void operator delete[](void* p) { free(p); }
42 COMMON_PRIVATE_INLINE void operator delete[](void* p, const std::nothrow_t&) throw() { free(p); }
43 #endif
44 
45 #endif // __COMMON_H__