MySQL  8.0.16
Source Code Documentation
thr_malloc.h
Go to the documentation of this file.
1 /* Copyright (c) 2006, 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 THR_MALLOC_INCLUDED
24 #define THR_MALLOC_INCLUDED
25 
26 #include <stddef.h>
27 
28 struct CHARSET_INFO;
29 struct MEM_ROOT;
30 typedef unsigned int PSI_memory_key;
31 extern thread_local MEM_ROOT **THR_MALLOC;
32 
33 void init_sql_alloc(PSI_memory_key key, MEM_ROOT *root, size_t block_size,
34  size_t pre_alloc_size);
35 
36 void *sql_alloc(size_t);
37 void *sql_calloc(size_t);
38 char *sql_strdup(const char *str);
39 char *sql_strmake(const char *str, size_t len);
40 void *sql_memdup(const void *ptr, size_t size);
41 char *sql_strmake_with_convert(const char *str, size_t arg_length,
42  const CHARSET_INFO *from_cs,
43  size_t max_res_length, const CHARSET_INFO *to_cs,
44  size_t *result_length);
45 
46 #endif /* THR_MALLOC_INCLUDED */
void init_sql_alloc(PSI_memory_key key, MEM_ROOT *root, size_t block_size, size_t pre_alloc_size)
Definition: thr_malloc.cc:45
char * sql_strmake_with_convert(const char *str, size_t arg_length, const CHARSET_INFO *from_cs, size_t max_res_length, const CHARSET_INFO *to_cs, size_t *result_length)
Definition: thr_malloc.cc:84
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46
unsigned int root
Definition: dbug_analyze.cc:514
char * sql_strdup(const char *str)
Definition: thr_malloc.cc:62
thread_local MEM_ROOT ** THR_MALLOC
Definition: mysqld.cc:1289
unsigned int PSI_memory_key
Definition: thr_malloc.h:29
void * sql_alloc(size_t)
Definition: thr_malloc.cc:51
void * sql_memdup(const void *ptr, size_t size)
Definition: thr_malloc.cc:78
unsigned int len
Definition: dbug_analyze.cc:216
Definition: m_ctype.h:358
static const char * key
Definition: suite_stubs.c:14
char * sql_strmake(const char *str, size_t len)
Definition: thr_malloc.cc:69
void * sql_calloc(size_t)
Definition: thr_malloc.cc:56
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77