Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10433 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52064 invoked by uid 1010); 14 Jun 2004 10:18:35 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 52040 invoked by uid 1007); 14 Jun 2004 10:18:35 -0000 To: internals@lists.php.net References: <40CC1D3C.9070605@php.net> Message-ID: Date: Mon, 14 Jun 2004 13:17:46 +0300 Organization: none Content-Type: text/plain; format=flowed; delsp=yes; charset=koi8-r MIME-Version: 1.0 Content-Transfer-Encoding: 8bit User-Agent: Opera M2/7.50 (Win32, build 3778) X-Posted-By: 217.23.116.150 Subject: Re: [PHP-DEV] Re: crc32() improvements From: valyala@tut.by ("Alexander Valyalkin") On Mon, 14 Jun 2004 11:00:33 +0200 (CEST), Derick Rethans wrote: >> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) >> == >> FAILURE) { >> return; >> } >> /* !!! there is no error check nr < 0 */ > > Of course not, that's pointless as a string can never have a > negative length. > :) Are you sure? I'm not. Look on declaration of [nr] variable: int nr; And answer, please, which value will be assigned to nr, if length of a string will be greater than 0x7fffffff on 32-bit architecture? >> len = 0 ; /* !!! remove it! */ > > Why? It's used one line below and you HAVE to initalize a variable. > I can't find any sense of the [len] variable. Can you? >> Below is corrected function with speed improvement in main cycle > > It also violates our coding standards BIG time. It is only idle talk. Can you provide any string from my code which violates your "coding standards"? By the way, your "coding standards" violates C standards on type of string (and any other byte arrays) length. Why are you use int instead of size_t?: typedef union _zvalue_value { long lval; /* long value */ double dval; /* double value */ struct { char *val; int len; /* !!!!!!!!!!!!! why int, not size_t ????? */ } str; HashTable *ht; /* hash table value */ zend_object obj; } zvalue_value; > And there is no reason to expand that macro at all Is significant speed improvement silly reason for you? -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/