本文整理汇总了C++中ALLOC_INIT_ZVAL函数的典型用法代码示例。如果您正苦于以下问题:C++ ALLOC_INIT_ZVAL函数的具体用法?C++ ALLOC_INIT_ZVAL怎么用?C++ ALLOC_INIT_ZVAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ALLOC_INIT_ZVAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: phalcon_array_append_string
int phalcon_array_append_string(zval **arr, char *value, int value_length, int separate TSRMLS_DC){
zval *zvalue;
ALLOC_INIT_ZVAL(zvalue);
Z_SET_REFCOUNT_P(zvalue, 0);
ZVAL_STRINGL(zvalue, value, value_length, 1);
return phalcon_array_append(arr, zvalue, separate TSRMLS_CC);
}
示例2: zephir_array_append_string
/**
* @brief Appends a string @a value to @a arr
* @param[in,out] arr Array
* @param value Value
* @param value_length Length of the value (usually <tt>strlen(value)</tt>)
* @param separate Flags (@c PH_SEPARATE: separate array if its reference count is greater than 1; @c arr will contain the separated array)
* @return Whether the operation succeeded
* @retval @c FAILURE Failure or @a arr is not an array
* @retval @c SUCCESS Success
* @throw @c E_WARNING if @a is not an array
* @see zephir_array_append()
*
* Equivalent to <tt>$arr[] = $value</tt> in PHP, where @c $value is a string.
*/
int zephir_array_append_string(zval **arr, char *value, uint value_length, int separate) {
zval *zvalue;
ALLOC_INIT_ZVAL(zvalue);
Z_SET_REFCOUNT_P(zvalue, 0);
ZVAL_STRINGL(zvalue, value, value_length, 1);
return zephir_array_append(arr, zvalue, separate);
}
示例3: zephir_array_append_long
/**
* @brief Appends a long integer @a value to @a arr
* @param[in,out] arr Array
* @param value Value
* @param separate Flags (@c PH_SEPARATE: separate array if its reference count is greater than 1; @c arr will contain the separated array)
* @return Whether the operation succeeded
* @retval @c FAILURE Failure or @a arr is not an array
* @retval @c SUCCESS Success
* @throw @c E_WARNING if @a is not an array
* @see zephir_array_append()
*
* Equivalent to <tt>$arr[] = $value</tt> in PHP, where @c $value is an integer.
*/
int zephir_array_append_long(zval **arr, long value, int separate) {
zval *zvalue;
ALLOC_INIT_ZVAL(zvalue);
Z_SET_REFCOUNT_P(zvalue, 0);
ZVAL_LONG(zvalue, value);
return zephir_array_append(arr, zvalue, separate ZEPHIR_DEBUG_PARAMS_DUMMY);
}
示例4: phalcon_array_append_long
int phalcon_array_append_long(zval **arr, long value, int separate TSRMLS_DC){
zval *zvalue;
ALLOC_INIT_ZVAL(zvalue);
Z_SET_REFCOUNT_P(zvalue, 0);
ZVAL_LONG(zvalue, value);
return phalcon_array_append(arr, zvalue, separate TSRMLS_CC);
}
示例5: PHP_METHOD
/** {{{ public ZeRecorder::fetchAll()
*/
PHP_METHOD(ze_recorder, fetchAll) {
zval * self = NULL;
zval * stmt = NULL;
long style = 0;
zval * style_z = NULL;
zval * success = NULL;
zval * row = NULL;
/* PDO::FETCH_ASSOC */
style = 2;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l"
, &style
) == FAILURE) {
WRONG_PARAM_COUNT;
}
/* call execute */
/* call fetch */
self = getThis();
stmt = zend_read_property(ze_recorder_ce, self, ZEND_STRL(ZE_STMT), 0 TSRMLS_CC);
do {
if (!stmt || Z_TYPE_P(stmt) != IS_OBJECT) {
ze_error(E_ERROR TSRMLS_CC, "recorder.fetch.stmt.not_object");
break;
}
zend_call_method(&stmt, Z_OBJCE_P(stmt), NULL, ZEND_STRL("execute"), &success, 0, NULL, NULL TSRMLS_CC);
if (!success || EG(exception)) {
break;
}
convert_to_boolean(success);
if (Z_BVAL_P(success) == 1) {
ALLOC_INIT_ZVAL(style_z);
ZVAL_LONG(style_z, style);
zend_call_method(&stmt, NULL, NULL, ZEND_STRL("fetchAll"), &row, 1, style_z, NULL TSRMLS_CC);
zval_dtor(style_z);
FREE_ZVAL(style_z);
}
zval_dtor(success);
FREE_ZVAL(success);
} while (0);
if (row) {
RETURN_ZVAL(row, 1, 1);
} else {
RETURN_FALSE;
}
}
示例6: signature
// time critical
bool PHPQt::qt_metacall(smokephp_object* o, Smoke::Stack args)
{
Context::setCallType( Context::SlotCall );
const QMetaObject* staticMetaObject = o->meta();
const int _id = args[2].s_int;
const int offset = staticMetaObject->methodOffset();
const QByteArray signature( staticMetaObject->method(_id).signature() );
const QByteArray metaMethodName = signature.left( signature.indexOf("(") );
//! - if we have a slot overridden in php user space: call it
//! @see InvokeSlot
if( PHPQt::methodExists( o->ce_ptr() , metaMethodName.constData()) ) {
pDebug( PHPQt::Slot ) << " userspace " << signature << o->ce_ptr()->name;
const int count = staticMetaObject->method( args[2].s_int ).parameterTypes().count() + 1;
// zval* zmem = ALLOCA_N(zval, count);
zval** zmem = (zval**) safe_emalloc( sizeof(zval*), count+1, 0);
for( int i=0;i<count;i++ )
{
ALLOC_INIT_ZVAL( zmem[i] );
}
// NOTICE is memory allocation safe here?
InvokeSlot c( o->smoke(), args, o->zval_ptr(), zmem, _id, staticMetaObject, (void**) args[3].s_voidp, metaMethodName );
c.next();
efree(zmem);
return true;
} else {
if ( staticMetaObject->indexOfSlot( signature ) != -1 )
{
pDebug( PHPQt::Slot ) << " C++ " << signature;
// return false means this will be done by smoke
return false;
} else {
// TODO error case for undefined methods, see php_qt proxyMethod
// const int i = staticMetaObject->indexOfSignal( signature );
// const int offset = staticMetaObject->methodOffset(); // The offset is the summary of all methods in the class's superclasses
pDebug( PHPQt::Signal ) << signature << staticMetaObject->className() << _id << staticMetaObject->methodOffset();
/* C++ */ //if( _id < offset ) { qWarning() << "got an id smaller than offset"; }
/**
* We go through QMetaObject::activate, because it can either be connected to a C++ Slot or a user space Slot
* cast to a QObject using smoke cast
* */
QObject* ptr = (QObject*) o->smoke()->cast( const_cast<void*>( o->ptr() ), o->classId(), cachedQObjectSmokeId );
void *_b[] = { 0, ((void**) args[3].s_voidp)[1] };
QMetaObject::activate( ptr, staticMetaObject, 0, _b );
return true; // success
}
} // else method exist
return false;
}
示例7: php_jq_filter
static void
php_jq_filter(zval **return_value, jq_state *jq, jv json, int flags TSRMLS_DC)
{
jv result;
jq_start(jq, jv_copy(json), 0);
if (jv_is_valid(result = jq_next(jq))) {
int multiple = 0;
while (1) {
zval *zv;
ALLOC_INIT_ZVAL(zv);
if (flags == JQ_OPT_RAW) {
if (jv_get_kind(result) == JV_KIND_STRING) {
ZVAL_STRING(zv, jv_string_value(result), 1);
} else {
jv dump = jv_dump_string(result, 0);
if (jv_is_valid(dump)) {
ZVAL_STRING(zv, jv_string_value(dump), 1);
}
jv_free(dump);
}
} else {
php_jv_dump(&zv, result TSRMLS_CC);
}
if (!jv_is_valid(result = jq_next(jq))) {
if (multiple) {
zend_hash_next_index_insert(Z_ARRVAL_PP(return_value),
&zv, sizeof(zv), NULL);
} else {
ZVAL_ZVAL(*return_value, zv, 1, 1);
}
break;
}
if (!multiple) {
multiple = 1;
array_init(*return_value);
}
zend_hash_next_index_insert(Z_ARRVAL_PP(return_value),
&zv, sizeof(zv), NULL);
}
} else {
jv_free(result);
if (PHP_JQ_G(display_errors)) {
PHP_JQ_ERR(E_WARNING, "filter parse error");
}
ZVAL_BOOL(*return_value, 0);
}
}
示例8: cp_unserialize
CPINLINE zval * cp_unserialize(char *data, int len) {
zval *unser_value;
ALLOC_INIT_ZVAL(unser_value);
php_unserialize_data_t var_hash;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (php_var_unserialize(&unser_value, (const unsigned char **) &data, (unsigned char *) data + len - 1, &var_hash TSRMLS_CC) != 1)
{
// php_error_docref(NULL TSRMLS_CC, E_NOTICE, "unser data is corrupted");
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return unser_value;
}
示例9: qb_add_array
static zval * qb_add_array(zval *array, const char *name) {
HashTable *ht = Z_ARRVAL_P(array);
zval *zvalue;
ALLOC_INIT_ZVAL(zvalue);
array_init(zvalue);
if(name) {
zend_hash_update(ht, name, (uint32_t) strlen(name) + 1, &zvalue, sizeof(zval *), NULL);
} else {
zend_hash_next_index_insert(ht, &zvalue, sizeof(zval *), NULL);
}
return zvalue;
}
示例10: php_jam_invoke_handler
void php_jam_invoke_handler(int type TSRMLS_DC, const char *error_filename, const uint error_lineno, const char *format, ...)
{
zval *event;
va_list args;
ALLOC_INIT_ZVAL(event);
array_init(event);
va_start(args, format);
php_jam_capture_error_ex(event, type, error_filename, error_lineno, 1, format, args TSRMLS_CC);
va_end(args);
}
示例11: phalcon_call_method_params_normal
/**
* Call methods that require parameters in a old-style secure way
*/
inline int phalcon_call_method_params_normal(zval *return_value, zval *object, char *method_name, int method_len, zend_uint param_count, zval *params[], int check, int noreturn TSRMLS_DC){
zval *fn = NULL;
int status = FAILURE;
zend_class_entry *ce, *active_scope = NULL;
if (check) {
if (!zend_hash_exists(&Z_OBJCE_P(object)->function_table, method_name, method_len+1)) {
return SUCCESS;
}
}
if (!noreturn) {
ALLOC_INIT_ZVAL(return_value);
}
PHALCON_ALLOC_ZVAL(fn);
ZVAL_STRINGL(fn, method_name, method_len, 1);
if (Z_TYPE_P(object) == IS_OBJECT) {
active_scope = EG(scope);
ce = Z_OBJCE_P(object);
phalcon_find_scope(ce, method_name, method_len TSRMLS_CC);
status = PHALCON_CALL_USER_FUNCTION(&ce->function_table, &object, fn, return_value, param_count, params TSRMLS_CC);
if (status == FAILURE) {
EG(scope) = active_scope;
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined method %s() on class %s", Z_STRVAL_P(fn), Z_OBJCE_P(object)->name);
status = FAILURE;
}
EG(scope) = active_scope;
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to method %s() on a non object", Z_STRVAL_P(fn));
status = FAILURE;
}
zval_ptr_dtor(&fn);
if (!noreturn) {
zval_ptr_dtor(&return_value);
return_value = NULL;
}
if (EG(exception)){
status = FAILURE;
}
if (status == FAILURE) {
phalcon_memory_restore_stack(TSRMLS_C);
}
return status;
}
示例12: phalcon_call_func_params
/**
* Call single function which requires arbitrary number of parameters
*/
int phalcon_call_func_params(zval *return_value, char *func_name, int func_length, zend_uint param_count, zval *params[], int noreturn, int fcache_pointer TSRMLS_DC){
zval *fn = NULL;
int status = FAILURE;
//zval ***params_array;
zval *local_retval_ptr = NULL;
//int i;
if (!noreturn) {
ALLOC_INIT_ZVAL(return_value);
}
PHALCON_ALLOC_ZVAL(fn);
ZVAL_STRINGL(fn, func_name, func_length, 1);
/*status = phalcon_cache_lookup_function(fn, fcache_pointer);
if (status == FAILURE) {
return FAILURE;
}*/
/*if(param_count){
params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
for (i=0; i<param_count; i++) {
params_array[i] = ¶ms[i];
}
} else {
params_array = NULL;
}*/
status = call_user_function(CG(function_table), NULL, fn, return_value, param_count, params TSRMLS_CC);
//status = phalcon_call_user_function_ex(CG(function_table), NULL, fn, &local_retval_ptr, param_count, params_array, 1, NULL, phalcon_fcall_cache[fcache_pointer] TSRMLS_CC);
if (status == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s()", func_name);
return FAILURE;
}
zval_ptr_dtor(&fn);
if (local_retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, local_retval_ptr);
}
if (!noreturn) {
zval_ptr_dtor(&return_value);
}
/*if (params_array) {
efree(params_array);
}*/
return status;
}
示例13: cpWorker_loop
static int cpWorker_loop(int worker_id)
{
CPWG.id = worker_id;
char fifo_name[CP_FIFO_NAME_LEN] = {0};
sprintf(fifo_name, "%s_%d", CP_FIFO_NAME_PRE, CPGC.group_id * CP_GROUP_LEN + worker_id); //client 2 worker
int pipe_fd_read = cpCreateFifo(fifo_name);
sprintf(fifo_name, "%s_%d_1", CP_FIFO_NAME_PRE, CPGC.group_id * CP_GROUP_LEN + worker_id); //worker 2 client
int pipe_fd_write = cpCreateFifo(fifo_name);
CPGS->workers[worker_id].pipe_fd_write = pipe_fd_write;
cpShareMemory *sm_obj = &(CPGS->workers[worker_id].sm_obj);
cpWorkerInfo event;
bzero(&event, sizeof (event));
int ret, len = 0;
int event_len = sizeof (event);
while (CPGS->running) {
zval *ret_value;
ALLOC_INIT_ZVAL(ret_value);
if (CPGS->workers[worker_id].pre_len) {
len = CPGS->workers[worker_id].pre_len;
CPGS->workers[worker_id].pre_len = 0;
CPWG.clientPid = CPGS->workers[worker_id].pre_pid;
} else {
do {
ret = cpFifoRead(pipe_fd_read, &event, event_len);
if (ret < 0) {
cpLog("fifo read Error: %s [%d]", strerror(errno), errno);
}
} while (event.pid != CPGS->workers[worker_id].CPid); //有可能有脏数据 读出来
if (!CPGS->workers[worker_id].run) {
CPGS->workers[worker_id].pre_len = event.len; //啊~~我要挂了,赶紧存起来 下次再用
CPGS->workers[worker_id].pre_pid = event.pid;
break;
}
len = event.len;
// cpLog("worker %d len",len);
CPWG.clientPid = event.pid;
}
if (sm_obj->mem == NULL) {
if ((sm_obj->mem = shmat(sm_obj->shmid, NULL, 0)) < 0) {
cpLog("attach sys mem error Error: %s [%d]", strerror(errno), errno);
}
}
if (ret < 0) {
cpLog("fifo read Error: %s [%d]", strerror(errno), errno);
}
php_msgpack_unserialize(ret_value, sm_obj->mem, len);
worker_onReceive(ret_value);
}
return SUCCESS;
}
示例14: phalcon_call_static_zval_func_params
/**
* Call single static function on a zval which requires parameters
*/
inline int phalcon_call_static_zval_func_params(zval *return_value, zval *mixed_name, char *method_name, int method_len, zend_uint param_count, zval *params[], int noreturn TSRMLS_DC){
zval *fn;
int status = FAILURE;
if (!noreturn) {
ALLOC_INIT_ZVAL(return_value);
}
ALLOC_INIT_ZVAL(fn);
array_init(fn);
add_next_index_zval(fn, mixed_name);
add_next_index_stringl(fn, method_name, method_len, 1);
status = phalcon_call_user_function(CG(function_table), NULL, fn, return_value, param_count, params TSRMLS_CC);
if (status == FAILURE) {
if(Z_TYPE_P(mixed_name) == IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", Z_STRVAL_P(mixed_name), method_name);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function not-callable::%s()", method_name);
}
}
zval_ptr_dtor(&fn);
if (!noreturn) {
zval_ptr_dtor(&return_value);
}
if (EG(exception)) {
status = FAILURE;
}
if (status == FAILURE) {
phalcon_memory_restore_stack(TSRMLS_C);
}
return status;
}
示例15: PHP_METHOD
PHP_METHOD(SpotifyPlaylist, getTracks)
{
zval tempretval, *type, *spotifyobject;
ALLOC_INIT_ZVAL(type);
Z_TYPE_P(type) = IS_LONG;
Z_LVAL_P(type) = 0;
spotifyobject = GET_THIS_PROPERTY(spotifyplaylist_ce, "spotify");
object_init_ex(return_value, spotifytrackiterator_ce);
SPOTIFY_METHOD3(SpotifyTrackIterator, __construct, &tempretval, return_value, getThis(), type, spotifyobject);
}