The code should be (*len)--; then the result is as desired, I'll adjust.
Ilia Alshanetsky
On 19-May-09, at 1:33 PM, Matteo Beccati wrote:
Ilia Alshanetsky ha scritto:
*len is a pointer to an integer, that is being decremented to
reduce the
overall length of the string to "remove" the NUL terminator. If you
remove the operation you'll end up with 2 NULs at the end of the
string.
As I said, I coulndn't find any reference to the fact that "the NUL
terminator is included in the byte count for TEXT values" in
sqlite3.h.
I don't want to argue about this, but here's a small test case that
hopefully proves that the code you added back is just useless, as it
doesn't do what you'd expect by reading the comment.
$ cat len.c; gcc -Wall len.c; ./a.out
#include <stdio.h>
#include <assert.h>
void decrease_len(int *len)
{
*len--;
}
int main(int argc, char **argv)
{
int len = 10;
decrease_len(&len);
assert(len == 9);
return 0;
}
len.c: In function ‘decrease_len’:
len.c:6: warning: value computed is not used
a.out: len.c:14: main: Assertion `len == 9' failed.
Aborted
Cheers
--
Matteo Beccati
OpenX - http://www.openx.org
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php