Re: [PHP4BETA] cvs: /php4 ChangeLog /php4/ext/standard basic_functions.c basic_functions.h
| From: | Chad Cunningham | Date: | Mon, 04 Oct 1999 21:45:44 +0000 |
| Subject: | Re: [PHP4BETA] cvs: /php4 ChangeLog /php4/ext/standard basic_functions.c basic_functions.h | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-5162@lists.php.net to get a copy of this message | ||
Any chance of getting a real shuffle in php4 to avoid the Solaris core dump problem? It's a
simple solution,
all I did with php3 was duplicate the _php3_hash_sort function and instead of calling qsort, did the
following.
> for (k=0; k<i-1; k++) {
> s = (k+1) + (int)((double)((i-1)-(k+1)+1) *
> #ifdef HAVE_LRAND48
> lrand48()
> #else
> #ifdef HAVE_RANDOM
> random()
> #else
> rand()
> #endif
> #endif
> /(PHP_RAND_MAX+1.0));
> t = arTmp[k];
> arTmp[k] = arTmp[s];
> arTmp[s] = t;
> }
Simple and no core dumps :) I also did some bench testing with this vs qsort on redhat6 with
php3.0.8, results
are at http://zeus1.tzo.com/diff.php3.