@@ -70,18 +70,15 @@ int _php_ibase_string_to_quad(char const *id, ISC_QUAD *qd) /* {{{ */
7070}
7171/* }}} */
7272
73- char * _php_ibase_quad_to_string (ISC_QUAD const qd ) /* {{{ */
73+ zend_string * _php_ibase_quad_to_string (ISC_QUAD const qd ) /* {{{ */
7474{
75- char * result ;
76-
7775 /* shortcut for most common case */
7876 if (sizeof (ISC_QUAD ) == sizeof (ISC_UINT64 )) {
79- spprintf ( & result , BLOB_ID_LEN + 1 , "0x%0*" LL_MASK "x" , 16 , * (ISC_UINT64 * )(void * ) & qd );
77+ return strpprintf ( BLOB_ID_LEN + 1 , "0x%0*" LL_MASK "x" , 16 , * (ISC_UINT64 * )(void * ) & qd );
8078 } else {
8179 ISC_UINT64 res = ((ISC_UINT64 ) qd .gds_quad_high << 0x20 ) | qd .gds_quad_low ;
82- spprintf ( & result , BLOB_ID_LEN + 1 , "0x%0*" LL_MASK "x" , 16 , res );
80+ return strpprintf ( BLOB_ID_LEN + 1 , "0x%0*" LL_MASK "x" , 16 , res );
8381 }
84- return result ;
8582}
8683/* }}} */
8784
@@ -347,7 +344,6 @@ static void _php_ibase_blob_end(INTERNAL_FUNCTION_PARAMETERS, int bl_end) /* {{{
347344{
348345 zval * blob_arg ;
349346 ibase_blob * ib_blob ;
350- char * s ;
351347
352348 RESET_ERRMSG ;
353349
@@ -367,10 +363,7 @@ static void _php_ibase_blob_end(INTERNAL_FUNCTION_PARAMETERS, int bl_end) /* {{{
367363 }
368364 ib_blob -> bl_handle = NULL ;
369365
370- s = _php_ibase_quad_to_string (ib_blob -> bl_qd );
371- // TODO: avoid double reallocation???
372- RETVAL_STRINGL (s , BLOB_ID_LEN );
373- efree (s );
366+ RETVAL_NEW_STR (_php_ibase_quad_to_string (ib_blob -> bl_qd ));
374367 } else { /* discard created blob */
375368 if (isc_cancel_blob (IB_STATUS , & ib_blob -> bl_handle )) {
376369 _php_ibase_error ();
@@ -550,7 +543,6 @@ PHP_FUNCTION(ibase_blob_import)
550543 ibase_trans * trans = NULL ;
551544 char bl_data [IBASE_BLOB_SEG ];
552545 php_stream * stream ;
553- char * s ;
554546
555547 RESET_ERRMSG ;
556548
@@ -578,11 +570,7 @@ PHP_FUNCTION(ibase_blob_import)
578570 if (isc_close_blob (IB_STATUS , & ib_blob .bl_handle )) {
579571 break ;
580572 }
581- s = _php_ibase_quad_to_string (ib_blob .bl_qd );
582- // TODO: avoid double reallocation???
583- RETVAL_STRINGL (s , BLOB_ID_LEN );
584- efree (s );
585- return ;
573+ RETURN_NEW_STR (_php_ibase_quad_to_string (ib_blob .bl_qd ));
586574 } while (0 );
587575
588576 _php_ibase_error ();
0 commit comments