xref: /PHP-5.6/ext/mysqlnd/mysqlnd_alloc.h (revision 49493a2d)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2006-2016 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Authors: Georg Richter <georg@mysql.com>                             |
16   |          Andrey Hristov <andrey@mysql.com>                           |
17   |          Ulf Wendel <uwendel@mysql.com>                              |
18   +----------------------------------------------------------------------+
19 */
20 
21 /* $Id: mysqlnd_debug.h 306938 2011-01-01 02:17:06Z felipe $ */
22 /* $Id: mysqlnd_debug.h 306938 2011-01-01 02:17:06Z felipe $ */
23 
24 #ifndef MYSQLND_ALLOC_H
25 #define MYSQLND_ALLOC_H
26 
27 PHPAPI extern const char * mysqlnd_debug_std_no_trace_funcs[];
28 
29 #define MYSQLND_MEM_D	TSRMLS_DC ZEND_FILE_LINE_ORIG_DC
30 #define MYSQLND_MEM_C	TSRMLS_CC ZEND_FILE_LINE_CC
31 
32 struct st_mysqlnd_allocator_methods
33 {
34 	void *	(*m_emalloc)(size_t size MYSQLND_MEM_D);
35 	void *	(*m_pemalloc)(size_t size, zend_bool persistent MYSQLND_MEM_D);
36 	void *	(*m_ecalloc)(unsigned int nmemb, size_t size MYSQLND_MEM_D);
37 	void *	(*m_pecalloc)(unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D);
38 	void *	(*m_erealloc)(void *ptr, size_t new_size MYSQLND_MEM_D);
39 	void *	(*m_perealloc)(void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D);
40 	void	(*m_efree)(void *ptr MYSQLND_MEM_D);
41 	void	(*m_pefree)(void *ptr, zend_bool persistent MYSQLND_MEM_D);
42 	void *	(*m_malloc)(size_t size MYSQLND_MEM_D);
43 	void *	(*m_calloc)(unsigned int nmemb, size_t size MYSQLND_MEM_D);
44 	void *	(*m_realloc)(void *ptr, size_t new_size MYSQLND_MEM_D);
45 	void	(*m_free)(void *ptr MYSQLND_MEM_D);
46 	char *	(*m_pestrndup)(const char * const ptr, size_t size, zend_bool persistent MYSQLND_MEM_D);
47 	char *	(*m_pestrdup)(const char * const ptr, zend_bool persistent MYSQLND_MEM_D);
48 	int		(*m_sprintf)(char **pbuf, size_t max_len, const char *format, ...);
49 	int		(*m_vsprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
50 	void	(*m_sprintf_free)(char * p);
51 };
52 
53 PHPAPI extern struct st_mysqlnd_allocator_methods mysqlnd_allocator;
54 
55 PHPAPI void *	_mysqlnd_emalloc(size_t size MYSQLND_MEM_D);
56 PHPAPI void *	_mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D);
57 PHPAPI void *	_mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
58 PHPAPI void *	_mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D);
59 PHPAPI void *	_mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D);
60 PHPAPI void *	_mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D);
61 PHPAPI void		_mysqlnd_efree(void *ptr MYSQLND_MEM_D);
62 PHPAPI void		_mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D);
63 PHPAPI void *	_mysqlnd_malloc(size_t size MYSQLND_MEM_D);
64 PHPAPI void *	_mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D);
65 PHPAPI void *	_mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D);
66 PHPAPI void		_mysqlnd_free(void *ptr MYSQLND_MEM_D);
67 PHPAPI char *	_mysqlnd_pestrndup(const char * const ptr, size_t size, zend_bool persistent MYSQLND_MEM_D);
68 PHPAPI char *	_mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_MEM_D);
69 PHPAPI int		_mysqlnd_sprintf(char **pbuf, size_t max_len, const char *format, ...);
70 PHPAPI void		_mysqlnd_sprintf_free(char * p);
71 PHPAPI int		_mysqlnd_vsprintf(char **pbuf, size_t max_len, const char *format, va_list ap);
72 
73 #define mnd_emalloc(size)				mysqlnd_allocator.m_emalloc((size) MYSQLND_MEM_C)
74 #define mnd_pemalloc(size, pers)		mysqlnd_allocator.m_pemalloc((size), (pers) MYSQLND_MEM_C)
75 #define mnd_ecalloc(nmemb, size)		mysqlnd_allocator.m_ecalloc((nmemb), (size) MYSQLND_MEM_C)
76 #define mnd_pecalloc(nmemb, size, p)	mysqlnd_allocator.m_pecalloc((nmemb), (size), (p) MYSQLND_MEM_C)
77 #define mnd_erealloc(ptr, new_size)		mysqlnd_allocator.m_erealloc((ptr), (new_size) MYSQLND_MEM_C)
78 #define mnd_perealloc(ptr, new_size, p)	mysqlnd_allocator.m_perealloc((ptr), (new_size), (p) MYSQLND_MEM_C)
79 #define mnd_efree(ptr)					mysqlnd_allocator.m_efree((ptr) MYSQLND_MEM_C)
80 #define mnd_pefree(ptr, pers)			mysqlnd_allocator.m_pefree((ptr), (pers) MYSQLND_MEM_C)
81 #define mnd_malloc(size)				mysqlnd_allocator.m_malloc((size) MYSQLND_MEM_C)
82 #define mnd_calloc(nmemb, size)			mysqlnd_allocator.m_calloc((nmemb), (size) MYSQLND_MEM_C)
83 #define mnd_realloc(ptr, new_size)		mysqlnd_allocator.m_realloc((ptr), (new_size) MYSQLND_MEM_C)
84 #define mnd_free(ptr)					mysqlnd_allocator.m_free((ptr) MYSQLND_MEM_C)
85 #define mnd_pestrndup(ptr, size, pers)	mysqlnd_allocator.m_pestrndup((ptr), (size), (pers) MYSQLND_MEM_C)
86 #define mnd_pestrdup(ptr, pers)			mysqlnd_allocator.m_pestrdup((ptr), (pers) MYSQLND_MEM_C)
87 #define mnd_sprintf(p, mx_len, fmt,...) mysqlnd_allocator.m_sprintf((p), (mx_len), (fmt), __VA_ARGS__)
88 #define mnd_vsprintf(p, mx_len, fmt,ap) mysqlnd_allocator.m_vsprintf((p), (mx_len), (fmt), (ap))
89 #define mnd_sprintf_free(p)				mysqlnd_allocator.m_sprintf_free((p))
90 
91 #endif /* MYSQLND_ALLOC_H */
92 
93 /*
94  * Local variables:
95  * tab-width: 4
96  * c-basic-offset: 4
97  * End:
98  * vim600: noet sw=4 ts=4 fdm=marker
99  * vim<600: noet sw=4 ts=4
100  */
101