cvs: php4 /ext/pgsql pgsql.c

From: Date: Thu, 04 Apr 2002 13:54:51 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10855@lists.php.net to get a copy of this message
yohgaki Thu Apr 4 08:54:51 2002 EDT Modified files: /php4/ext/pgsql pgsql.c Log: Clean up pg_escape_*() Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.167 php4/ext/pgsql/pgsql.c:1.168 --- php4/ext/pgsql/pgsql.c:1.167 Thu Apr 4 05:25:12 2002 +++ php4/ext/pgsql/pgsql.c Thu Apr 4 08:54:51 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.167 2002/04/04 10:25:12 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.168 2002/04/04 13:54:51 yohgaki Exp $ */ #include <stdlib.h> @@ -2391,19 +2391,15 @@ PHP_FUNCTION(pg_escape_string) { char *from = NULL, *to = NULL; - int len; + size_t from_len, to_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &from, &len) == FAILURE) { + &from, &from_len) == FAILURE) { return; } - to = (char *)emalloc(len*2+1); - len = (int)PQescapeString(to, from, strlen(from)); - if (len < 0) { - efree(to); - RETURN_FALSE; - } - RETURN_STRINGL(to, len, 0); + to = (char *)emalloc(from_len*2+1); + to_len = (int)PQescapeString(to, from, from_len); + RETURN_STRINGL(to, to_len, 0); } /* }}} */ @@ -2412,18 +2408,14 @@ PHP_FUNCTION(pg_escape_bytea) { char *from = NULL, *to = NULL; - int len; + size_t from_len, to_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &from, &len) == FAILURE) { + &from, &from_len) == FAILURE) { return; } - to = (char *)PQescapeBytea((unsigned char*)from, strlen(from), (size_t *)&len); - if (len < 0) { - /* Don't need to free "to" here*/ - RETURN_FALSE; - } - RETURN_STRINGL(to, len, 1); + to = (char *)PQescapeBytea((unsigned char*)from, from_len, &to_len); + RETVAL_STRINGL(to, to_len-1, 1); /* to_len includes addtional '\0' */ free(to); } /* }}} */

« previous php.cvs (#10855) next »