Re: cvs: php-src(PHP_5_3) /ext/pdo_sqlite sqlite_statement.c
| From: | Matteo Beccati | Date: | Tue, 19 May 2009 17:33:09 +0000 |
| Subject: | Re: cvs: php-src(PHP_5_3) /ext/pdo_sqlite sqlite_statement.c | ||
| References: | 1 2 3 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-58019@lists.php.net to get a copy of this message | ||
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