# sprintf or spprintf

- Thread: https://externals.io/message/45062
- Original archive: https://news-web.php.net/php.internals/45062
- Started by Lester Caine on 2009-07-23T12:22:05+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #45062 — Lester Caine — 2009-07-23T12:22:05+00:00

URL: https://externals.io/message/45062#45062

We are still battling problems with 64 bit builds and it seems that how 
spprintf is handled is the key to the problem. On my own builds on Linux64 and 
Windows64, the following works ...

char *_php_ibase_quad_to_string(ISC_QUAD const qd) /* {{{ */
{
char *result;
  	
/* shortcut for most common case */
if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void 
*) &qd);
} else {
ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | qd.gds_quad_low;
spprintf(&result, BLOB_ID_LEN+1, "0x%0*" LL_MASK "x", 16, res);
}
return result;
}

but people are reporting that they have to switch back to the previous sprintf 
based version to get it to work ...
char *_php_ibase_quad_to_string(ISC_QUAD const qd) /* {{{ */
{
char *result = (char *) emalloc(BLOB_ID_LEN+1);
/* shortcut for most common case */
if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
sprintf(result, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd);
} else {
ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high << 0x20) | qd.gds_quad_low;
sprintf(result, "0x%0*" LL_MASK "x", 16, res);
}
result[BLOB_ID_LEN] = '\0';
return result;
}

It would seem that while the 'memory allocation standard' was changed around 
5.2.0, at which time php_interbase developed the problem, there was nothing 
actually done to the code around 5.2.6 which fixed it? Only how it was 
compiled seems to have changed .... although I'm not certain that I am 
actually looking in the right place following the move to SVN

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
