Re: Access raw buffer (for binary data)
| From: | Zeev Suraski | Date: | Tue, 01 Nov 2005 08:54:54 +0000 |
| Subject: | Re: Access raw buffer (for binary data) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19878@lists.php.net to get a copy of this message | ||
At 10:47 01/11/2005, Rasmus Lerdorf wrote:
Derick Rethans wrote:It's a mix of both, to clarify: - For 'PHP strings', i.e. strings that go back into PHP, it is a strict requirement. - For 'internal' strings, assuming internal means strings used by the extension that never go anywhere beyond that, there aren't any requirements of any kind, other than using the memory allocator perhaps. For that matter, strings are like any other kind of data structure. So it all depends on what people understand when they read 'PHP strings' or 'internal'. ZeevOn Tue, 1 Nov 2005, Marco Bambini wrote:That's not really a PHP requirement, but more of a good convention to prevent something external from falling off the end of a string. If you are just working with it internally you don't need it.Thanks a lot Rasmus, I have just (wrongly) assumed that the convert_to_string function tries to search for the 0 termination character.It doesn't - but, PHP strings always require \0 to be the last character so you always need to allocate one more byte and put the \0 in there - even for binary data.