Skip to content

Commit d2ccea1

Browse files
Remove wrappers for *printf functions (#7313)
1 parent 9d0db2e commit d2ccea1

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

ext/mysqlnd/mysqlnd_alloc.c

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -360,40 +360,7 @@ static char * _mysqlnd_pestrdup(const char * const ptr, bool persistent MYSQLND_
360360
/* }}} */
361361

362362

363-
364-
365-
#endif /* MYSQLND_DEBUG_MEMORY */
366-
367-
/* {{{ _mysqlnd_sprintf_free */
368-
static void _mysqlnd_sprintf_free(char * p)
369-
{
370-
efree(p);
371-
}
372-
/* }}} */
373-
374-
375-
/* {{{ _mysqlnd_sprintf */
376-
static int _mysqlnd_sprintf(char ** pbuf, size_t max_len, const char *format, ...)
377-
{
378-
int len;
379-
va_list ap;
380-
va_start(ap, format);
381-
len = vspprintf(pbuf, max_len, format, ap);
382-
va_end(ap);
383-
return len;
384-
}
385-
/* }}} */
386-
387-
/* {{{ _mysqlnd_vsprintf */
388-
static int _mysqlnd_vsprintf(char ** pbuf, size_t max_len, const char * format, va_list ap)
389-
{
390-
return vspprintf(pbuf, max_len, format, ap);
391-
}
392-
/* }}} */
393-
394-
395-
396-
#if MYSQLND_DEBUG_MEMORY == 0
363+
#else
397364

398365
/* {{{ mysqlnd_zend_mm_emalloc */
399366
static void * mysqlnd_zend_mm_emalloc(size_t size MYSQLND_MEM_D)
@@ -486,7 +453,7 @@ static char * mysqlnd_zend_mm_pestrdup(const char * const ptr, bool persistent M
486453
}
487454
/* }}} */
488455

489-
#endif
456+
#endif /* MYSQLND_DEBUG_MEMORY */
490457

491458

492459
PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
@@ -502,10 +469,7 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
502469
_mysqlnd_pefree,
503470
_mysqlnd_pememdup,
504471
_mysqlnd_pestrndup,
505-
_mysqlnd_pestrdup,
506-
_mysqlnd_sprintf,
507-
_mysqlnd_vsprintf,
508-
_mysqlnd_sprintf_free
472+
_mysqlnd_pestrdup
509473
#else
510474
mysqlnd_zend_mm_emalloc,
511475
mysqlnd_zend_mm_pemalloc,
@@ -517,9 +481,6 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
517481
mysqlnd_zend_mm_pefree,
518482
mysqlnd_zend_mm_pememdup,
519483
mysqlnd_zend_mm_pestrndup,
520-
mysqlnd_zend_mm_pestrdup,
521-
_mysqlnd_sprintf,
522-
_mysqlnd_vsprintf,
523-
_mysqlnd_sprintf_free,
484+
mysqlnd_zend_mm_pestrdup
524485
#endif
525486
};

ext/mysqlnd/mysqlnd_alloc.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ struct st_mysqlnd_allocator_methods
3636
char * (*m_pememdup)(const char * const ptr, size_t size, bool persistent MYSQLND_MEM_D);
3737
char * (*m_pestrndup)(const char * const ptr, size_t size, bool persistent MYSQLND_MEM_D);
3838
char * (*m_pestrdup)(const char * const ptr, bool persistent MYSQLND_MEM_D);
39-
int (*m_sprintf)(char **pbuf, size_t max_len, const char *format, ...);
40-
int (*m_vsprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
41-
void (*m_sprintf_free)(char * p);
4239
};
4340

4441
PHPAPI extern struct st_mysqlnd_allocator_methods mysqlnd_allocator;
@@ -54,9 +51,9 @@ PHPAPI extern struct st_mysqlnd_allocator_methods mysqlnd_allocator;
5451
#define mnd_pememdup(ptr, size, pers) mysqlnd_allocator.m_pememdup((ptr), (size), (pers) MYSQLND_MEM_C)
5552
#define mnd_pestrndup(ptr, size, pers) mysqlnd_allocator.m_pestrndup((ptr), (size), (pers) MYSQLND_MEM_C)
5653
#define mnd_pestrdup(ptr, pers) mysqlnd_allocator.m_pestrdup((ptr), (pers) MYSQLND_MEM_C)
57-
#define mnd_sprintf(p, mx_len, fmt,...) mysqlnd_allocator.m_sprintf((p), (mx_len), (fmt), __VA_ARGS__)
58-
#define mnd_vsprintf(p, mx_len, fmt,ap) mysqlnd_allocator.m_vsprintf((p), (mx_len), (fmt), (ap))
59-
#define mnd_sprintf_free(p) mysqlnd_allocator.m_sprintf_free((p))
54+
#define mnd_sprintf(p, mx_len, fmt,...) spprintf((p), (mx_len), (fmt), __VA_ARGS__)
55+
#define mnd_vsprintf(p, mx_len, fmt,ap) vspprintf((p), (mx_len), (fmt), (ap))
56+
#define mnd_sprintf_free(p) efree((p))
6057

6158
static inline MYSQLND_STRING mnd_dup_cstring(const MYSQLND_CSTRING str, const bool persistent)
6259
{

0 commit comments

Comments
 (0)