Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_alloc.c zend_alloc.h

From: Date: Wed, 21 Aug 2002 07:44:40 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_alloc.c zend_alloc.h
References: 1 2 3 4  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-341@lists.php.net to get a copy of this message
On Wed, Aug 21, 2002 at 09:32:50AM +0200, Stefan Esser wrote: > > > Can't you think of a faster way than using division? I bet there's a better > > > > > > way. > > If you consider that one integer division compared to the whole overhead > of calling (e)malloc is nothing I doubt another way is needed. > Another way would be to first check if both operands are below half of > size_t (16 bit) (!((nmemb|size)&0xFFFF0000) but that is harder to > implement because of 64 bit compatibility... Or Do we have constants > for this already??? another way is to count the > bits... if they are /8 < sizeof (size_t) then there will be no integer > overflow... But this will need several loop+shift operations... > I would be really suprised if that is still faster than a single > integer division. > > > maybe we should get rid of ecalloc in ZE2 completely? > > What is the problem with ecalloc? If you think it is too slow you can > use emalloc+memset. Infact there are only a few places in php where > it is used at all... So speed is not really sooo important. the interesting thing about having ecalloc as a macro was, that if size and nelms are known at compile-time the compiler can perfectly (inline) optimize the needed memset. this was pointed out by sascha based on some analysis done by "apache"-dean. the problem is the integer overflow - a agree, so lets move the problem "out of our way" in ZE2, nuke ecalloc and add a function like emalloc0() which works exaclty like emalloc but also initializes the memory returned to \0. re, tc

« previous php.zend-engine.cvs (#341) next »