summaryrefslogtreecommitdiff
path: root/ext/interbase/ibase_events.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/interbase/ibase_events.c')
-rw-r--r--ext/interbase/ibase_events.c75
1 files changed, 25 insertions, 50 deletions
diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c
index 64842dd505..b4c204ba26 100644
--- a/ext/interbase/ibase_events.c
+++ b/ext/interbase/ibase_events.c
@@ -126,9 +126,8 @@ static void _php_ibase_event_block(ibase_db_link *ib_link, unsigned short count,
Waits for any one of the passed Interbase events to be posted by the database, and returns its name */
PHP_FUNCTION(ibase_wait_event)
{
- zval ***args;
+ zval **args[16];
ibase_db_link *ib_link;
- int num_args;
char *event_buffer, *result_buffer, *events[15];
unsigned short i = 0, event_count = 0, buffer_size;
unsigned long occurred_event[15];
@@ -140,25 +139,22 @@ PHP_FUNCTION(ibase_wait_event)
WRONG_PARAM_COUNT;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &num_args) == FAILURE) {
- return;
+ if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ RETURN_FALSE;
}
if (Z_TYPE_PP(args[0]) == IS_RESOURCE) {
- if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link, ibase_db_link *, args[0], -1, "InterBase link", le_link, le_plink)) {
- efree(args);
- RETURN_FALSE;
- }
+
+ ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, args[0], -1, "InterBase link", le_link, le_plink);
i = 1;
+
} else {
+
if (ZEND_NUM_ARGS() > 15) {
- efree(args);
WRONG_PARAM_COUNT;
}
- if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link, ibase_db_link *, NULL, IBG(default_link), "InterBase link", le_link, le_plink)) {
- efree(args);
- RETURN_FALSE;
- }
+
+ ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link), "InterBase link", le_link, le_plink);
}
for (; i < ZEND_NUM_ARGS(); ++i) {
@@ -173,7 +169,6 @@ PHP_FUNCTION(ibase_wait_event)
if (isc_wait_for_event(IB_STATUS, &ib_link->handle, buffer_size, event_buffer, result_buffer)) {
_php_ibase_error(TSRMLS_C);
_php_ibase_event_free(event_buffer,result_buffer);
- efree(args);
RETURN_FALSE;
}
@@ -183,7 +178,6 @@ PHP_FUNCTION(ibase_wait_event)
if (occurred_event[i]) {
char *result = estrdup(events[i]);
_php_ibase_event_free(event_buffer,result_buffer);
- efree(args);
RETURN_STRING(result,0);
}
}
@@ -191,7 +185,6 @@ PHP_FUNCTION(ibase_wait_event)
/* If we reach this line, isc_wait_for_event() did return, but we don't know
which event fired. */
_php_ibase_event_free(event_buffer,result_buffer);
- efree(args);
RETURN_FALSE;
}
/* }}} */
@@ -267,71 +260,55 @@ PHP_FUNCTION(ibase_set_event_handler)
* link resource id (int) as arguments. The value returned from the function is
* used to determine if the event handler should remain set.
*/
- char *cb_name;
- zval ***args, **cb_arg;
+
+ zval **args[17], **cb_arg;
ibase_db_link *ib_link;
ibase_event *event;
unsigned short i = 1, buffer_size;
- int link_res_id, num_args;
+ int link_res_id;
RESET_ERRMSG;
-
- /* Minimum and maximum number of arguments allowed */
+
+ /* no more than 15 events */
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 17) {
WRONG_PARAM_COUNT;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &num_args) == FAILURE) {
- return;
+ if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ RETURN_FALSE;
}
/* get a working link */
if (Z_TYPE_PP(args[0]) != IS_STRING) {
- /* resource, callback, event_1 [, ... event_15]
- * No more than 15 events
- */
- if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 17) {
- efree(args);
- WRONG_PARAM_COUNT;
- }
cb_arg = args[1];
i = 2;
- if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link, ibase_db_link *, args[0], -1, "InterBase link", le_link, le_plink)) {
- efree(args);
- RETURN_FALSE;
- }
+ ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, args[0], -1,
+ "InterBase link", le_link, le_plink);
convert_to_long_ex(args[0]);
link_res_id = Z_LVAL_PP(args[0]);
} else {
- /* callback, event_1 [, ... event_15]
- * No more than 15 events
- */
- if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 16) {
- efree(args);
+
+ if (ZEND_NUM_ARGS() > 16) {
WRONG_PARAM_COUNT;
}
cb_arg = args[0];
- if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link, ibase_db_link *, NULL, IBG(default_link), "InterBase link", le_link, le_plink)) {
- efree(args);
- RETURN_FALSE;
- }
+ ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, IBG(default_link),
+ "InterBase link", le_link, le_plink);
link_res_id = IBG(default_link);
}
/* get the callback */
- if (!zend_is_callable(*cb_arg, 0, &cb_name TSRMLS_CC)) {
- _php_ibase_module_error("Callback argument %s is not a callable function" TSRMLS_CC, cb_name);
- efree(cb_name);
- efree(args);
+ if (!zend_is_callable(*cb_arg, 0, NULL TSRMLS_CC)) {
+ _php_ibase_module_error("Callback argument %s is not a callable function"
+ TSRMLS_CC, Z_STRVAL_PP(cb_arg));
RETURN_FALSE;
}
- efree(cb_name);
/* allocate the event resource */
event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0);
@@ -362,7 +339,6 @@ PHP_FUNCTION(ibase_set_event_handler)
_php_ibase_error(TSRMLS_C);
efree(event);
- efree(args);
RETURN_FALSE;
}
@@ -371,7 +347,6 @@ PHP_FUNCTION(ibase_set_event_handler)
ZEND_REGISTER_RESOURCE(return_value, event, le_event);
zend_list_addref(Z_LVAL_P(return_value));
- efree(args);
}
/* }}} */