MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
service_thd_alloc.h
Go to the documentation of this file.
1 #ifndef MYSQL_SERVICE_THD_ALLOC_INCLUDED
2 /* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
30 #ifndef MYSQL_ABI_CHECK
31 #include <stdlib.h>
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
39 {
40  char *str;
41  size_t length;
42 };
44 
45 extern struct thd_alloc_service_st {
46  void *(*thd_alloc_func)(MYSQL_THD, unsigned int);
47  void *(*thd_calloc_func)(MYSQL_THD, unsigned int);
48  char *(*thd_strdup_func)(MYSQL_THD, const char *);
49  char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int);
50  void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int);
51  MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *,
52  const char *, unsigned int, int);
53 } *thd_alloc_service;
54 
55 #ifdef MYSQL_DYNAMIC_PLUGIN
56 
57 #define thd_alloc(thd,size) (thd_alloc_service->thd_alloc_func((thd), (size)))
58 
59 #define thd_calloc(thd,size) (thd_alloc_service->thd_calloc_func((thd), (size)))
60 
61 #define thd_strdup(thd,str) (thd_alloc_service->thd_strdup_func((thd), (str)))
62 
63 #define thd_strmake(thd,str,size) \
64  (thd_alloc_service->thd_strmake_func((thd), (str), (size)))
65 
66 #define thd_memdup(thd,str,size) \
67  (thd_alloc_service->thd_memdup_func((thd), (str), (size)))
68 
69 #define thd_make_lex_string(thd, lex_str, str, size, allocate_lex_string) \
70  (thd_alloc_service->thd_make_lex_string_func((thd), (lex_str), (str), \
71  (size), (allocate_lex_string)))
72 
73 #else
74 
87 void *thd_alloc(MYSQL_THD thd, unsigned int size);
91 void *thd_calloc(MYSQL_THD thd, unsigned int size);
95 char *thd_strdup(MYSQL_THD thd, const char *str);
99 char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
103 void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
104 
118 MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
119  const char *str, unsigned int size,
120  int allocate_lex_string);
121 
122 #endif
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #define MYSQL_SERVICE_THD_ALLOC_INCLUDED
129 #endif
130