On Wed, Dec 3, 2014 at 6:37 PM, j adams <[email protected]> wrote:

> I'm working on a PECL extension and I need to convert a long:
> long index;
>
> into a char* that I can pass to another function. I obviously want to avoid
> buffer overflows and memory leaks and I'd also like to avoid introducing
> any code that is machine-dependent on the sizeo or endianness of a long.
>
> Is there some canonical/recommended way to accomplish this?
>
>
Hello,

depending on the use-case, see:

http://lxr.php.net/xref/PHP_5_6/main/spprintf.c#812

http://lxr.php.net/xref/PHP_5_6/ext/standard/php_smart_str.h#89

http://lxr.php.net/xref/PHP_5_6/Zend/zend_operators.h#343

-- Mikko

Reply via email to