From e219ec144ef6682b71e135fd18654ee1bb4676b4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 7 Jan 2019 12:28:51 +0100 Subject: Implement typed properties RFC: https://wiki.php.net/rfc/typed_properties_v2 This is a squash of PR #3734, which is a squash of PR #3313. Co-authored-by: Bob Weinand Co-authored-by: Joe Watkins Co-authored-by: Dmitry Stogov --- ext/sysvmsg/sysvmsg.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'ext/sysvmsg') diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index a00b73ee8a..0f7726f334 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -318,7 +318,7 @@ PHP_FUNCTION(msg_remove_queue) } /* }}} */ -/* {{{ proto mixed msg_receive(resource queue, int desiredmsgtype, int &msgtype, int maxsize, mixed message [, bool unserialize=true [, int flags=0 [, int errorcode]]]) +/* {{{ proto mixed msg_receive(resource queue, int desiredmsgtype, int &msgtype, int maxsize, mixed &message [, bool unserialize=true [, int flags=0 [, int &errorcode]]]) Send a message of type msgtype (must be > 0) to a message queue */ PHP_FUNCTION(msg_receive) { @@ -332,7 +332,7 @@ PHP_FUNCTION(msg_receive) RETVAL_FALSE; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz/lz/|blz/", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlzlz|blz", &queue, &desiredmsgtype, &out_msgtype, &maxsize, &out_message, &do_unserialize, &flags, &zerrcode) == FAILURE) { return; @@ -368,19 +368,12 @@ PHP_FUNCTION(msg_receive) result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags); - zval_ptr_dtor(out_msgtype); - zval_ptr_dtor(out_message); - ZVAL_LONG(out_msgtype, 0); - ZVAL_FALSE(out_message); - - if (zerrcode) { - zval_ptr_dtor(zerrcode); - ZVAL_LONG(zerrcode, 0); - } - if (result >= 0) { /* got it! */ - ZVAL_LONG(out_msgtype, messagebuffer->mtype); + ZEND_TRY_ASSIGN_LONG(out_msgtype, messagebuffer->mtype); + if (zerrcode) { + ZEND_TRY_ASSIGN_LONG(zerrcode, 0); + } RETVAL_TRUE; if (do_unserialize) { @@ -391,16 +384,21 @@ PHP_FUNCTION(msg_receive) PHP_VAR_UNSERIALIZE_INIT(var_hash); if (!php_var_unserialize(&tmp, &p, p + result, &var_hash)) { php_error_docref(NULL, E_WARNING, "message corrupted"); + ZEND_TRY_ASSIGN_FALSE(out_message); RETVAL_FALSE; } else { - ZVAL_COPY_VALUE(out_message, &tmp); + ZEND_TRY_ASSIGN_VALUE(out_message, &tmp); } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); } else { - ZVAL_STRINGL(out_message, messagebuffer->mtext, result); + ZEND_TRY_ASSIGN_STRINGL(out_message, messagebuffer->mtext, result); + } + } else { + ZEND_TRY_ASSIGN_LONG(out_msgtype, 0); + ZEND_TRY_ASSIGN_FALSE(out_message); + if (zerrcode) { + ZEND_TRY_ASSIGN_LONG(zerrcode, errno); } - } else if (zerrcode) { - ZVAL_LONG(zerrcode, errno); } efree(messagebuffer); } @@ -420,7 +418,7 @@ PHP_FUNCTION(msg_send) RETVAL_FALSE; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz|bbz/", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz|bbz", &queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE) { return; } @@ -486,8 +484,7 @@ PHP_FUNCTION(msg_send) if (result == -1) { php_error_docref(NULL, E_WARNING, "msgsnd failed: %s", strerror(errno)); if (zerror) { - zval_ptr_dtor(zerror); - ZVAL_LONG(zerror, errno); + ZEND_TRY_ASSIGN_LONG(zerror, errno); } } else { RETVAL_TRUE; -- cgit v1.2.1