diff options
Diffstat (limited to 'ext/mysqlnd/mysqlnd_alloc.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_alloc.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index 808f3ae41e..9f77910acd 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -510,6 +510,35 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME } /* }}} */ + +/* {{{ _mysqlnd_sprintf */ +PHPAPI int _mysqlnd_sprintf(char ** pbuf, size_t max_len, const char *format, ...) +{ + int len; + va_list ap; + va_start(ap, format); + len = vspprintf(pbuf, max_len, format, ap); + va_end(ap); + return len; +} +/* }}} */ + + +/* {{{ _mysqlnd_sprintf_free */ +PHPAPI void _mysqlnd_sprintf_free(char * p) +{ + efree(p); +} +/* }}} */ + + +PHPAPI int _mysqlnd_vsprintf(char ** pbuf, size_t max_len, const char * format, va_list ap) +{ + return vspprintf(pbuf, max_len, format, ap); +} +/* }}} */ + + #define MYSQLND_DEBUG_MEMORY 1 #if MYSQLND_DEBUG_MEMORY == 0 @@ -644,7 +673,10 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator = _mysqlnd_realloc, _mysqlnd_free, _mysqlnd_pestrndup, - _mysqlnd_pestrdup + _mysqlnd_pestrdup, + _mysqlnd_sprintf, + _mysqlnd_vsprintf, + _mysqlnd_sprintf_free #else mysqlnd_zend_mm_emalloc, mysqlnd_zend_mm_pemalloc, @@ -660,6 +692,8 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator = mysqlnd_zend_mm_free, mysqlnd_zend_mm_pestrndup, mysqlnd_zend_mm_pestrdup + sprintf, + mysqlnd_zend_mm_efree, #endif }; |