MySQL 8.0.31
Source Code Documentation
service_mysql_alloc.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 2022, 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 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 */
38typedef int myf_t;
39
40typedef void *(*mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags);
41typedef void *(*mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size,
42 myf_t flags);
43typedef void (*mysql_claim_t)(const void *ptr, bool claim);
44typedef void (*mysql_free_t)(void *ptr);
45typedef void *(*my_memdup_t)(PSI_memory_key key, const void *from,
46 size_t length, myf_t flags);
47typedef char *(*my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags);
48typedef 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
117extern void *my_malloc(PSI_memory_key key, size_t size, myf_t flags);
118extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size,
119 myf_t flags);
120extern void my_claim(const void *ptr, bool claim);
121extern void my_free(void *ptr);
122extern void *my_memdup(PSI_memory_key key, const void *from, size_t length,
123 myf_t flags);
124extern char *my_strdup(PSI_memory_key key, const char *from, myf_t flags);
125extern char *my_strndup(PSI_memory_key key, const char *from, size_t length,
126 myf_t flags);
127
128#endif
129
130#endif
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
static int flags[50]
Definition: hp_test1.cc:39
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
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:59
char *(* my_strdup_t)(PSI_memory_key key, const char *from, myf_t flags)
Definition: service_mysql_alloc.h:47
char * my_strdup(PSI_memory_key key, const char *from, myf_t flags)
Definition: my_malloc.cc:483
void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags)
Definition: my_malloc.cc:475
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:80
void(* mysql_free_t)(void *ptr)
Definition: service_mysql_alloc.h:44
struct mysql_malloc_service_st * mysql_malloc_service
Definition: service_mysql_alloc.h:103
void(* mysql_claim_t)(const void *ptr, bool claim)
Definition: service_mysql_alloc.h:43
void *(* mysql_malloc_t)(PSI_memory_key key, size_t size, myf_t flags)
Definition: service_mysql_alloc.h:40
void * my_malloc(PSI_memory_key key, size_t size, myf_t flags)
Allocates size bytes of memory.
Definition: my_memory.cc:56
void my_claim(const void *ptr, bool claim)
Definition: my_malloc.cc:308
int myf_t
Definition: service_mysql_alloc.h:38
void *(* mysql_realloc_t)(PSI_memory_key key, void *ptr, size_t size, myf_t flags)
Definition: service_mysql_alloc.h:41
char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags)
Definition: my_malloc.cc:491
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_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags)
Definition: my_malloc.cc:271
This service allows plugins to allocate and free memory through the server's memory handling routines...
Definition: service_mysql_alloc.h:58
mysql_realloc_t mysql_realloc
Reallocates a block of memory.
Definition: service_mysql_alloc.h:70
my_memdup_t my_memdup
Copies a buffer into a new buffer.
Definition: service_mysql_alloc.h:88
my_strndup_t my_strndup
Copies no more than n characters of a string into a new buffer.
Definition: service_mysql_alloc.h:100
my_strdup_t my_strdup
Copies a string into a new buffer.
Definition: service_mysql_alloc.h:94
mysql_free_t mysql_free
Frees a block of memory.
Definition: service_mysql_alloc.h:82
mysql_malloc_t mysql_malloc
Allocates a block of memory.
Definition: service_mysql_alloc.h:64
mysql_claim_t mysql_claim
Re-instruments a block of memory.
Definition: service_mysql_alloc.h:76