MiniOB
1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
src
common
mm
debug_new.h
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2
miniob is licensed under Mulan PSL v2.
3
You can use this software according to the terms and conditions of the Mulan PSL v2.
4
You may obtain a copy of Mulan PSL v2 at:
5
http://license.coscl.org.cn/MulanPSL2
6
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9
See 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>
19
namespace
common {
20
21
/* Prototypes */
22
bool
check_leaks();
23
void
*
operator
new
(
size_t
size,
const
char
*file,
int
line);
24
void
*
operator
new
[](
size_t
size,
const
char
*file,
int
line);
25
#ifndef NO_PLACEMENT_DELETE
26
void
operator
delete
(
void
*pointer,
const
char
*file,
int
line);
27
void
operator
delete
[](
void
*pointer,
const
char
*file,
int
line);
28
#endif
// NO_PLACEMENT_DELETE
29
void
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 */
48
extern
bool
new_verbose_flag;
// default to false: no verbose information
49
extern
bool
new_autocheck_flag;
// default to true: call check_leaks() on exit
50
51
}
// namespace common
制作者
1.9.5