cvs: /php4/ext/standard array.c php_array.h

From: Date: Sat, 11 Dec 1999 22:42:32 +0000
Subject: cvs: /php4/ext/standard array.c php_array.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-7801@lists.php.net to get a copy of this message
andrei Sat Dec 11 17:42:32 1999 EDT Modified files: /php4/ext/standard array.c php_array.h Log: Added array globals in preparation for multisort() changes. Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.11 php4/ext/standard/array.c:1.12 --- php4/ext/standard/array.c:1.11 Wed Dec 1 12:21:52 1999 +++ php4/ext/standard/array.c Sat Dec 11 17:42:01 1999 @@ -38,6 +38,12 @@ #include "php_array.h" #include "basic_functions.h" +#ifdef ZTS +int array_globals_id; +#else +php_array_globals array_globals; +#endif + #define EXTR_OVERWRITE 0 #define EXTR_SKIP 1 #define EXTR_PREFIX_SAME 2 @@ -96,7 +102,7 @@ "Array Functions", /* extension name */ array_functions, /* function list */ PHP_MINIT(array), /* process startup */ - NULL, /* process shutdown */ + PHP_MSHUTDOWN(array), /* process shutdown */ NULL, /* request startup */ NULL, /* request shutdown */ NULL, /* extension info */ @@ -107,6 +113,10 @@ { ELS_FETCH(); +#ifdef ZTS + array_globals_id = ts_allocate_id(sizeof(php_array_globals), NULL, NULL); +#endif + REGISTER_LONG_CONSTANT("EXTR_OVERWRITE", EXTR_OVERWRITE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("EXTR_SKIP", EXTR_SKIP, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("EXTR_PREFIX_SAME", EXTR_PREFIX_SAME, CONST_CS | CONST_PERSISTENT); @@ -115,6 +125,15 @@ return SUCCESS; } +PHP_MSHUTDOWN_FUNCTION(array) +{ +#ifdef ZTS + ts_free_id(array_globals_id); +#endif + + return SUCCESS; +} + static int array_key_compare(const void *a, const void *b) { Bucket *f; @@ -1941,6 +1960,7 @@ int r; int result = 0; zval temp; + ARRAYLS_FETCH(); r = 0; do { @@ -1962,6 +1982,7 @@ int argc; int array_size; int i, k; + ARRAYLS_FETCH(); /* Get the argument count and check it */ argc = ARG_COUNT(ht); @@ -2012,6 +2033,7 @@ /* Do the actual sort */ qsort(indirect, array_size, sizeof(Bucket **), multisort_compare); + /* Restructure the arrays based on sorted indirect */ HANDLE_BLOCK_INTERRUPTIONS(); for (i = 0; i < argc; i++) { hash = (*args[i])->value.ht; Index: php4/ext/standard/php_array.h diff -u php4/ext/standard/php_array.h:1.3 php4/ext/standard/php_array.h:1.4 --- php4/ext/standard/php_array.h:1.3 Sun Dec 5 05:29:06 1999 +++ php4/ext/standard/php_array.h Sat Dec 11 17:42:01 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_array.h,v 1.3 1999/12/05 10:29:06 ssb Exp $ */ +/* $Id: php_array.h,v 1.4 1999/12/11 22:42:01 andrei Exp $ */ #ifndef _PHP_ARRAY_H #define _PHP_ARRAY_H @@ -36,7 +36,7 @@ #define array_module_ptr &array_module_entry PHP_MINIT_FUNCTION(array); -PHP_RINIT_FUNCTION(array); +PHP_MSHUTDOWN_FUNCTION(array); PHP_FUNCTION(ksort); PHP_FUNCTION(krsort); @@ -79,6 +79,28 @@ HashTable* _phpi_splice(HashTable *, int, int, zval ***, int, HashTable **); int multisort_compare(const void *a, const void *b); + +typedef struct { + int *multisort_flags; +} php_array_globals; + +#ifdef ZTS +#define ARRAYLS_D php_array_globals *array_globals +#define ARRAYLS_DC , ARRAYLS_D +#define ARRAYLS_C array_globals +#define ARRAYLS_CC , ARRAYLS_C +#define ARRAYG(v) (array_globals->v) +#define ARRAYLS_FETCH() php_array_globals *array_globals = ts_resource(array_globals_id) +extern int array_globals_id; +#else +#define ARRAYLS_D +#define ARRAYLS_DC +#define ARRAYLS_C +#define ARRAYLS_CC +#define ARRAYG(v) (array_globals.v) +#define ARRAYLS_FETCH() +extern php_array_globals array_globals; +#endif #define phpext_array_ptr array_module_ptr #endif /* _PHP_ARRAY_H */

« previous php.version4 (#7801) next »