MySQL  8.0.17
Source Code Documentation
service_mysql_alloc.h
Go to the documentation of this file.
1 /* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
24 #define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
25 
26 /**
27  @file include/mysql/service_mysql_alloc.h
28 */
29 
30 #ifndef MYSQL_ABI_CHECK
31 #include <stdlib.h>
32 #endif
33 
34 /* PSI_memory_key */
36 
37 /* myf */
38 typedef int myf_t;
39 
40 typedef void *(*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags);
41 typedef void *(*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size,
42  myf_t flags);
43 typedef void (*mysql_claim_t)(const void *ptr);
44 typedef void (*mysql_free_t)(void *ptr);
45 typedef void *(*my_memdup_t)(PSI_memory_key key, const void *from,
46  size_t length, myf_t flags);
47 typedef char *(*my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags);
48 typedef char *(*my_strndup_t)(PSI_memory_key key, const char *from,
49  size_t length, myf_t flags);
50 
51 /**
52  @ingroup group_ext_plugin_services
53 
54  This service allows plugins to allocate and free memory through the server's
55  memory handling routines.
56  This allows uniform memory handling and instrumentation.
57 */
59  /**
60  Allocates a block of memory
61 
62  @sa my_malloc
63  */
65  /**
66  Reallocates a block of memory
67 
68  @sa my_realloc
69  */
71  /**
72  Re-instruments a block of memory
73 
74  @sa my_claim
75  */
77  /**
78  Frees a block of memory
79 
80  @sa my_free
81  */
83  /**
84  Copies a buffer into a new buffer
85 
86  @sa my_memdup
87  */
89  /**
90  Copies a string into a new buffer
91 
92  @sa my_strdup
93  */
95  /**
96  Copies no more than n characters of a string into a new buffer
97 
98  @sa my_strndup
99  */
101 };
102 
104 
105 #ifdef MYSQL_DYNAMIC_PLUGIN
106 
107 #define my_malloc mysql_malloc_service->mysql_malloc
108 #define my_realloc mysql_malloc_service->mysql_realloc
109 #define my_claim mysql_malloc_service->mysql_claim
110 #define my_free mysql_malloc_service->mysql_free
111 #define my_memdup mysql_malloc_service->my_memdup
112 #define my_strdup mysql_malloc_service->my_strdup
113 #define my_strndup mysql_malloc_service->my_strndup
114 
115 #else
116 
117 extern void *my_malloc(PSI_memory_key key, size_t size, myf_t flags);
118 extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size,
119  myf_t flags);
120 extern void my_claim(const void *ptr);
121 extern void my_free(void *ptr);
122 extern void *my_memdup(PSI_memory_key key, const void *from, size_t length,
123  myf_t flags);
124 extern char *my_strdup(PSI_memory_key key, const char *from, myf_t flags);
125 extern char *my_strndup(PSI_memory_key key, const char *from, size_t length,
126  myf_t flags);
127 
128 #endif
129 
130 #endif
void(* mysql_claim_t)(const void *ptr)
Definition: service_mysql_alloc.h:43
char *(* my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags)
Definition: service_mysql_alloc.h:47
my_memdup_t my_memdup
Copies a buffer into a new buffer.
Definition: service_mysql_alloc.h:88
Performance schema instrumentation interface.
mysql_realloc_t mysql_realloc
Reallocates a block of memory.
Definition: service_mysql_alloc.h:70
char * my_strdup(PSI_memory_key key, const char *from, myf_t flags)
Definition: my_malloc.cc:292
void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags)
Definition: my_malloc.cc:285
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46
void *(* mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags)
Definition: service_mysql_alloc.h:40
int myf_t
Definition: service_mysql_alloc.h:38
void * my_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags)
Definition: my_malloc.cc:94
void * my_malloc(PSI_memory_key key, size_t size, myf_t flags)
Below functions are used by the components.
Definition: my_memory.cc:57
mysql_malloc_t mysql_malloc
Allocates a block of memory.
Definition: service_mysql_alloc.h:64
my_strndup_t my_strndup
Copies no more than n characters of a string into a new buffer.
Definition: service_mysql_alloc.h:100
void *(* my_memdup_t)(PSI_memory_key key, const void *from, size_t length, myf_t flags)
Definition: service_mysql_alloc.h:45
char *(* my_strndup_t)(PSI_memory_key key, const char *from, size_t length, myf_t flags)
Definition: service_mysql_alloc.h:48
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
static const char * key
Definition: suite_stubs.c:14
This service allows plugins to allocate and free memory through the server&#39;s memory handling routines...
Definition: service_mysql_alloc.h:58
void my_claim(const void *ptr)
Definition: my_malloc.cc:131
struct mysql_malloc_service_st * mysql_malloc_service
Definition: service_mysql_alloc.h:103
char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags)
Definition: my_malloc.cc:300
void *(* mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size, myf_t flags)
Definition: service_mysql_alloc.h:41
void(* mysql_free_t)(void *ptr)
Definition: service_mysql_alloc.h:44
static int flags[50]
Definition: hp_test1.cc:39
my_strdup_t my_strdup
Copies a string into a new buffer.
Definition: service_mysql_alloc.h:94
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
mysql_free_t mysql_free
Frees a block of memory.
Definition: service_mysql_alloc.h:82
mysql_claim_t mysql_claim
Re-instruments a block of memory.
Definition: service_mysql_alloc.h:76