MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
connection_control_memory.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef CONNECTION_CONTROL_MEMORY_H
25#define CONNECTION_CONTROL_MEMORY_H
26
28#include <limits>
29#include <memory>
30#include "connection_control.h"
31#include "include/my_sys.h"
32
33namespace connection_control {
34template <class T>
36 void *allocated_memory =
38 return allocated_memory ? reinterpret_cast<T>(allocated_memory) : nullptr;
39}
40
42 public:
43 static void *operator new(size_t size) noexcept {
44 return Connection_control_malloc<void *>(size);
45 }
46 static void *operator new[](size_t size) noexcept {
47 return Connection_control_malloc<void *>(size);
48 }
49 static void operator delete(void *ptr) { my_free(ptr); }
50 static void operator delete[](void *ptr) { my_free(ptr); }
51};
52} // namespace connection_control
53
54#endif // CONNECTION_CONTROL_MEMORY_H
Definition: connection_control_memory.h:41
PSI_memory_key key_connection_delay_memory
Definition: connection_control.cc:55
#define MY_WME
Definition: my_sys.h:131
#define MYF(v)
Definition: my_inttypes.h:97
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
Common header for many mysys elements.
Definition: connection_control.h:70
T Connection_control_malloc(size_t size)
Definition: connection_control_memory.h:35
size_t size(const char *const c)
Definition: base64.h:46