CVS update: php3/functions

From: Date: Mon, 21 Sep 1998 16:03:38 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1328@lists.php.net to get a copy of this message
Date: Monday September 21, 1998 @ 12:03 Author: zeev Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv21905/functions Modified Files: basic_functions.c basic_functions.h Log Message: Reversed the changes to register_shutdown_function() Removed register_shutdown_method() These were causing random crash problems Index: php3/functions/basic_functions.c diff -c php3/functions/basic_functions.c:1.219 php3/functions/basic_functions.c:1.220 *** php3/functions/basic_functions.c:1.219 Sun Sep 20 18:43:46 1998 --- php3/functions/basic_functions.c Mon Sep 21 12:03:36 1998 *************** *** 89,95 **** void user_shutdown_function_dtor(pval *user_shutdown_function_name); int user_shutdown_function_executor(pval *user_shutdown_function_name); void php3_call_shutdown_functions(void); - static void _php3_register_shutdown_function( pval **params, int arg_count, int is_method ); function_entry basic_functions[] = { {"intval", int_value, NULL}, --- 89,94 ---- *************** *** 279,286 **** {"call_user_method", php3_call_user_method, NULL}, PHP_FE(register_shutdown_function, NULL) ! PHP_FE(register_shutdown_method, NULL) ! {NULL, NULL, NULL} }; --- 278,284 ---- {"call_user_method", php3_call_user_method, NULL}, PHP_FE(register_shutdown_function, NULL) ! {NULL, NULL, NULL} }; *************** *** 1593,1598 **** --- 1591,1607 ---- } + void user_shutdown_function_dtor(pval *user_shutdown_function_name) + { + pval retval; + + if (call_user_function(&GLOBAL(function_table), NULL, user_shutdown_function_name, &retval, 0, NULL)==SUCCESS) { + pval_destructor(&retval); + } + pval_destructor(user_shutdown_function_name); + } + + int user_shutdown_function_executor(pval *user_shutdown_function_name) { return 1; *************** *** 1606,1744 **** } } - - void user_shutdown_function_dtor(pval *arg) - { - pval retval; - pval **params; - int i = 0, param_count; - - param_count = _php3_hash_num_elements( arg->value.ht ); - - if ( param_count < 2 ) { - /* no function to call */ - pval_destructor( arg ); - return; - } - - params = (pval **) emalloc(sizeof(pval *) * param_count); - - for ( i = 0; i < param_count; i++ ) { - _php3_hash_index_find( arg->value.ht, i, (void **) &params[i] ); - } - - if ( params[0]->type == IS_LONG ) { - if ( call_user_function(&GLOBAL(function_table), params[2], params[1], &retval, param_count - 3, params + 3 )==SUCCESS) { - pval_destructor(&retval); - } - } else { - if ( call_user_function(&GLOBAL(function_table), NULL, params[1], &retval, param_count - 2, params + 2 )==SUCCESS) { - pval_destructor(&retval); - } - } - - pval_destructor( arg ); - efree( params ); - } - ! static void _php3_register_shutdown_function( pval **params, int arg_count, int is_method ) { ! pval param_array, type_temp; ! HashTable *destroy; ! int i; ! ! if ( array_init( &param_array ) == FAILURE ) { ! return; ! } ! destroy = param_array.value.ht; ! ! /* just use type_temp to mark which kind of thing we're registering */ ! if ( is_method ) { ! /* registering a method */ ! type_temp.type = IS_LONG; ! } else { ! /* registering a function */ ! type_temp.type = IS_STRING; ! } ! if ( _php3_hash_next_index_pointer_insert(param_array.value.ht, &type_temp )==FAILURE) { ! php3_error(E_WARNING, "Couldn't register shutdown function %s()", params[0]->value.str.val ); ! _php3_hash_destroy( destroy ); ! efree( destroy ); ! return; ! } ! ! for ( i = 0; i < arg_count; i++ ) { ! if ( _php3_hash_next_index_pointer_insert(param_array.value.ht, params[i] )==FAILURE) { ! php3_error(E_WARNING, "Couldn't register shutdown function %s()", params[0]->value.str.val ); ! _php3_hash_destroy( destroy ); ! efree( destroy ); ! return; ! } } ! ! pval_copy_constructor( &param_array ); ! if (!user_shutdown_function_names) { user_shutdown_function_names = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init(user_shutdown_function_names, 0, NULL, (void (*)(void *))user_shutdown_function_dtor, 0); - } - - if (_php3_hash_next_index_insert(user_shutdown_function_names, &param_array, sizeof(pval), NULL)==FAILURE) { - php3_error(E_WARNING, "Couldn't register shutdown function %s()", params[0]->value.str.val ); - } - - _php3_hash_destroy( destroy ); - efree( destroy ); - } - - - PHP_FUNCTION(register_shutdown_function) - { - pval **params; - int arg_count = ARG_COUNT(ht); - - if ( arg_count < 1 ) { - WRONG_PARAM_COUNT; } ! ! params = (pval **) emalloc(sizeof(pval)*arg_count); ! ! if (getParametersArray(ht, arg_count, params)==FAILURE) { ! efree(params); ! RETURN_FALSE; ! } ! ! _php3_register_shutdown_function( params, arg_count, 0 ); ! efree( params ); ! } ! ! ! PHP_FUNCTION(register_shutdown_method) ! { ! pval **params; ! int arg_count = ARG_COUNT(ht); ! ! if ( arg_count < 2 ) { ! WRONG_PARAM_COUNT; ! } ! ! params = (pval **) emalloc(sizeof(pval)*arg_count); ! ! if (getParametersArray(ht, arg_count, params)==FAILURE) { ! efree(params); ! RETURN_FALSE; ! } ! ! if (params[1]->type != IS_OBJECT) { ! php3_error(E_WARNING,"2nd argument to register_shutdown_method must be an object\n"); ! efree(params); ! RETURN_FALSE; ! } ! ! _php3_register_shutdown_function( params, arg_count, 1 ); ! efree( params ); } /* --- 1615,1639 ---- } } ! PHP_FUNCTION(register_shutdown_function) { ! pval *arg, shutdown_function_name; ! if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)==FAILURE) { ! WRONG_PARAM_COUNT; } ! ! convert_to_string(arg); if (!user_shutdown_function_names) { user_shutdown_function_names = (HashTable *) emalloc(sizeof(HashTable)); _php3_hash_init(user_shutdown_function_names, 0, NULL, (void (*)(void *))user_shutdown_function_dtor, 0); } ! ! shutdown_function_name = *arg; ! pval_copy_constructor(&shutdown_function_name); ! ! _php3_hash_next_index_insert(user_shutdown_function_names, &shutdown_function_name, sizeof(pval), NULL); } /* Index: php3/functions/basic_functions.h diff -c php3/functions/basic_functions.h:1.32 php3/functions/basic_functions.h:1.33 *** php3/functions/basic_functions.h:1.32 Thu Sep 17 05:24:05 1998 --- php3/functions/basic_functions.h Mon Sep 21 12:03:37 1998 *************** *** 29,35 **** */ ! /* $Id: basic_functions.h,v 1.32 1998/09/17 09:24:05 cslawi Exp $ */ #ifndef _BASIC_FUNCTIONS_H #define _BASIC_FUNCTIONS_H --- 29,35 ---- */ ! /* $Id: basic_functions.h,v 1.33 1998/09/21 16:03:37 zeev Exp $ */ #ifndef _BASIC_FUNCTIONS_H #define _BASIC_FUNCTIONS_H *************** *** 94,100 **** extern void php3_call_user_method(INTERNAL_FUNCTION_PARAMETERS); PHP_FUNCTION(register_shutdown_function); - PHP_FUNCTION(register_shutdown_method); #if HAVE_PUTENV typedef struct { --- 94,99 ---- -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1328) next »