php - Return same array (zval) as passed in to a function -


i tried create new function in extension takes array parameter adds entry that same instance of array , returns instance again.

so code far:

php_function(make_array) {         // array_init(return_value); // tried transform default null array          if (zend_parse_parameters(zend_num_args() tsrmls_cc, "a", &return_value) == failure) {                 return_false;         }          add_assoc_long(return_value, "answer", 42);          return; } 

but null return value or if uncomment array_init(return_value); return_value empty array.

so why behavior? , did understand wrong?

using return_value directly part of zpp argument typically not done (actually, never); it's commonly done introducing regular zval * container , return_zval or retval_zval macro used:

php_function(make_array) {     zval *arr;      if (zend_parse_parameters(zend_num_args() tsrmls_cc, "a", &arr) == failure) {         return;     }      add_assoc_long(arr, "answer", 42);     return_zval(arr, 0, 0); } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -