MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
debug_new.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by Longda on 2010
13//
14
15#pragma once
16
17#include <new>
18#include <stdlib.h>
19namespace common {
20
21/* Prototypes */
22bool check_leaks();
23void *operator new(size_t size, const char *file, int line);
24void *operator new[](size_t size, const char *file, int line);
25#ifndef NO_PLACEMENT_DELETE
26void operator delete(void *pointer, const char *file, int line);
27void operator delete[](void *pointer, const char *file, int line);
28#endif // NO_PLACEMENT_DELETE
29void operator delete[](void *); // MSVC 6 requires this declaration
30
31/* Macros */
32#ifndef DEBUG_NEW_NO_NEW_REDEFINITION
33#define new DEBUG_NEW
34#define DEBUG_NEW new (__FILE__, __LINE__)
35#define debug_new new
36#else
37#define debug_new new (__FILE__, __LINE__)
38#endif // DEBUG_NEW_NO_NEW_REDEFINITION
39#ifdef DEBUG_NEW_EMULATE_MALLOC
40
41#define malloc(s) ((void *)(debug_new char[s]))
42
43#define free(p) delete[](char *)(p)
44
45#endif // DEBUG_NEW_EMULATE_MALLOC
46
47/* Control flags */
48extern bool new_verbose_flag; // default to false: no verbose information
49extern bool new_autocheck_flag; // default to true: call check_leaks() on exit
50
51} // namespace common