Re: cvs: php4 /ext/mssql php_mssql.c
| From: | Andi Gutmans | Date: | Wed, 09 May 2001 16:58:12 +0000 |
| Subject: | Re: cvs: php4 /ext/mssql php_mssql.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-5629@lists.php.net to get a copy of this message | ||
Frank,
There still is a problem. If you emalloc(res_length) then the str.len can not be res_length. The emalloc() needs to contain the trailing NULL. So I'm not sure if dbconvert() returns you the length of the string with or without the trailing NULL but in any case it should either be emalloc(res_length+1) & manually add trailing NULL or set str.len to res_length -1.
Andi
At 04:20 PM 5/9/2001 +0000, Frank M. Kromann wrote:
fmk Wed May 9 09:20:36 2001 EDTModified files:/php4/ext/mssql php_mssql.cLog: Getting rid of memset. Index: php4/ext/mssql/php_mssql.c diff -u php4/ext/mssql/php_mssql.c:1.44 php4/ext/mssql/php_mssql.c:1.45--- php4/ext/mssql/php_mssql.c:1.44 Tue May 8 12:24:14 2001+++ php4/ext/mssql/php_mssql.c Wed May 9 09:20:34 2001 @@ -16,7 +16,7 @@+----------------------------------------------------------------------+*/ -/* $Id: php_mssql.c,v 1.44 2001/05/08 19:24:14 fmk Exp $ */ +/* $Id: php_mssql.c,v 1.45 2001/05/09 16:20:34 fmk Exp $ */ #ifdef COMPILE_DL_MSSQL #define HAVE_MSSQL 1 @@ -760,13 +760,8 @@if (column_type == SQLDATETIME) res_length += 10;res_buf = (char *) emalloc(res_length); - memset(res_buf, 0, res_length + 1); - dbconvert(NULL,column_type,dbdata(mssql_ptr->link,offset), res_length,SQLCHAR,res_buf,-1);-- while (res_length>0 && (res_buf[res_length-1] == ' ' || res_buf[res_length-1] == 0)) { /* nuke trailing whitespace */ - res_length--; - } - res_buf[res_length] = 0; + res_length = dbconvert(NULL,column_type,dbdata(mssql_ptr->link,offset), res_length,SQLCHAR,res_buf,-1);+result->value.str.val = res_buf; result->value.str.len = res_length; result->type = IS_STRING;@@ -805,15 +800,10 @@int res_length = dbdatlen(mssql_ptr->link,offset) + 1; if (column_type == SQLDATETIM4) res_length += 14; if (column_type == SQLDATETIME) res_length += 10;-- res_buf = (unsigned char *) emalloc(res_length+1); - memset(res_buf, 0, res_length + 1); - dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length, SQLCHAR,res_buf,-1);- while (res_length>0 && (res_buf[res_length-1] == ' ' || res_buf[res_length-1] == 0)) { /* nuke trailing whitespace */ - res_length--; - } - res_buf[res_length] = 0; + res_buf = (unsigned char *) emalloc(res_length); + res_length = dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length, SQLCHAR,res_buf,-1);+result->value.str.val = res_buf; result->value.str.len = res_length; result->type = IS_STRING;-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net