Re: best practice for converting a long to char* in a PECL extension?

From: Date: Wed, 03 Dec 2014 21:43:39 +0000
Subject: Re: best practice for converting a long to char* in a PECL extension?
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-12460@lists.php.net to get a copy of this message
On Wed, Dec 3, 2014 at 6:37 PM, j adams <zardozrocks@gmail.com> 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

« previous php.pecl.dev (#12460) next »