本文整理汇总了C++中ecalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ ecalloc函数的具体用法?C++ ecalloc怎么用?C++ ecalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ecalloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: php_couchbase_store_impl
PHP_COUCHBASE_LOCAL
void php_couchbase_store_impl(INTERNAL_FUNCTION_PARAMETERS, lcb_storage_t op, int multi)
{
lcb_error_t retval;
php_couchbase_res *couchbase_res;
php_couchbase_ctx *ctx;
time_t exp = {0};
unsigned int flags = 0;
char *payload, *cas = NULL;
size_t payload_len = 0;
unsigned long long cas_v = 0;
long expire = 0, cas_len = 0;
if (multi) { /* multi-get */
zval *akeys, **ppzval;
char *key = NULL;
uint klen = 0;
ulong idx;
int key_type, nkey = 0;
PHP_COUCHBASE_GET_PARAMS(couchbase_res,
PHP_COUCHBASE_ARG_F_FUNCTIONAL,
"a|l",
&akeys, &expire);
if (pcbc_check_expiry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0,
expire, &exp) == -1) {
/* Incorrect expiry time */
return;
}
ctx = ecalloc(1, sizeof(php_couchbase_ctx));
ctx->res = couchbase_res;
ctx->rv = return_value;
array_init(ctx->rv);
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(akeys));
zend_hash_has_more_elements(Z_ARRVAL_P(akeys)) == SUCCESS;
zend_hash_move_forward(Z_ARRVAL_P(akeys))) {
if (zend_hash_get_current_data(Z_ARRVAL_P(akeys), (void **)&ppzval) == FAILURE) {
continue;
}
switch ((key_type = zend_hash_get_current_key(Z_ARRVAL_P(akeys), &key, &idx, 0))) {
case HASH_KEY_IS_LONG:
spprintf(&key, 0, "%ld", idx);
break;
case HASH_KEY_IS_STRING:
break;
default:
continue;
}
if (!(klen = strlen(key))) {
continue;
}
payload = php_couchbase_zval_to_payload(*ppzval, &payload_len,
&flags,
couchbase_res->serializer,
couchbase_res->compressor
TSRMLS_CC);
if (payload == NULL) {
RETURN_FALSE;
}
if (couchbase_res->prefix_key_len) {
char *new_key;
klen = spprintf(&new_key, 0, "%s_%s", couchbase_res->prefix_key, key);
if (key_type == HASH_KEY_IS_LONG) {
efree(key);
}
key = new_key;
}
{
lcb_store_cmd_t cmd;
lcb_store_cmd_t *commands[] = { &cmd };
memset(&cmd, 0, sizeof(cmd));
cmd.v.v0.operation = op;
cmd.v.v0.key = key;
cmd.v.v0.nkey = klen;
cmd.v.v0.bytes = payload;
cmd.v.v0.nbytes = payload_len;
cmd.v.v0.flags = flags;
cmd.v.v0.exptime = exp;
retval = lcb_store(couchbase_res->handle, ctx,
1, (const lcb_store_cmd_t * const *)commands);
}
efree(payload);
if (couchbase_res->prefix_key_len || HASH_KEY_IS_LONG == key_type) {
efree(key);
}
if (LCB_SUCCESS != retval) {
efree(ctx);
couchbase_report_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0,
cb_lcb_exception,
"Failed to schedule set request: %s",
lcb_strerror(couchbase_res->handle,
//.........这里部分代码省略.........
示例2: php_yar_request_instance
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_yar.h"
#include "yar_exception.h"
#include "yar_response.h"
#include "yar_request.h"
yar_request_t * php_yar_request_instance(zval *body TSRMLS_DC) /* {{{ */ {
yar_request_t *req;
zval **ppzval;
HashTable *ht;
req = (yar_request_t *)ecalloc(sizeof(yar_request_t), 1);
if (IS_ARRAY != Z_TYPE_P(body)) {
return req;
}
ht = Z_ARRVAL_P(body);
if (zend_hash_find(ht, "i", sizeof("i"), (void**)&ppzval) == SUCCESS) {
if (IS_LONG != Z_TYPE_PP(ppzval)) {
convert_to_long(*ppzval);
}
req->id = Z_LVAL_PP(ppzval);
}
if (zend_hash_find(ht, "m", sizeof("m"), (void**)&ppzval) == SUCCESS) {
if (IS_STRING != Z_TYPE_PP(ppzval)) {
示例3: pgsql_handle_preparer
static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len, pdo_stmt_t *stmt, zval *driver_options)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt));
int scrollable;
int ret;
char *nsql = NULL;
size_t nsql_len = 0;
int emulate = 0;
int execute_only = 0;
S->H = H;
stmt->driver_data = S;
stmt->methods = &pgsql_stmt_methods;
scrollable = pdo_attr_lval(driver_options, PDO_ATTR_CURSOR,
PDO_CURSOR_FWDONLY) == PDO_CURSOR_SCROLL;
if (scrollable) {
if (S->cursor_name) {
efree(S->cursor_name);
}
spprintf(&S->cursor_name, 0, "pdo_crsr_%08x", ++H->stmt_counter);
emulate = 1;
} else if (driver_options) {
if (pdo_attr_lval(driver_options, PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, H->disable_native_prepares) == 1) {
php_error_docref(NULL, E_DEPRECATED, "PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead");
emulate = 1;
}
if (pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES, H->emulate_prepares) == 1) {
emulate = 1;
}
if (pdo_attr_lval(driver_options, PDO_PGSQL_ATTR_DISABLE_PREPARES, H->disable_prepares) == 1) {
execute_only = 1;
}
} else {
emulate = H->disable_native_prepares || H->emulate_prepares;
execute_only = H->disable_prepares;
}
if (!emulate && PQprotocolVersion(H->server) > 2) {
stmt->supports_placeholders = PDO_PLACEHOLDER_NAMED;
stmt->named_rewrite_template = "$%d";
ret = pdo_parse_params(stmt, (char*)sql, sql_len, &nsql, &nsql_len);
if (ret == 1) {
/* query was re-written */
sql = nsql;
} else if (ret == -1) {
/* couldn't grok it */
strcpy(dbh->error_code, stmt->error_code);
return 0;
}
if (!execute_only) {
/* prepared query: set the query name and defer the
actual prepare until the first execute call */
spprintf(&S->stmt_name, 0, "pdo_stmt_%08x", ++H->stmt_counter);
}
if (nsql) {
S->query = nsql;
} else {
S->query = estrdup(sql);
}
return 1;
}
stmt->supports_placeholders = PDO_PLACEHOLDER_NONE;
return 1;
}
示例4: ecalloc
static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) /* {{{ */
{
spl_dllist_object *intern;
zend_class_entry *parent = class_type;
int inherited = 0;
intern = ecalloc(1, sizeof(spl_dllist_object) + zend_object_properties_size(parent));
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
intern->flags = 0;
intern->traverse_position = 0;
intern->debug_info = NULL;
if (orig) {
spl_dllist_object *other = Z_SPLDLLIST_P(orig);
intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) {
intern->llist = (spl_ptr_llist *)spl_ptr_llist_init(other->llist->ctor, other->llist->dtor);
spl_ptr_llist_copy(other->llist, intern->llist);
intern->traverse_pointer = intern->llist->head;
SPL_LLIST_CHECK_ADDREF(intern->traverse_pointer);
} else {
intern->llist = other->llist;
intern->traverse_pointer = intern->llist->head;
SPL_LLIST_CHECK_ADDREF(intern->traverse_pointer);
}
intern->flags = other->flags;
} else {
intern->llist = (spl_ptr_llist *)spl_ptr_llist_init(spl_ptr_llist_zval_ctor, spl_ptr_llist_zval_dtor);
intern->traverse_pointer = intern->llist->head;
SPL_LLIST_CHECK_ADDREF(intern->traverse_pointer);
}
while (parent) {
if (parent == spl_ce_SplStack) {
intern->flags |= (SPL_DLLIST_IT_FIX | SPL_DLLIST_IT_LIFO);
intern->std.handlers = &spl_handler_SplDoublyLinkedList;
} else if (parent == spl_ce_SplQueue) {
intern->flags |= SPL_DLLIST_IT_FIX;
intern->std.handlers = &spl_handler_SplDoublyLinkedList;
}
if (parent == spl_ce_SplDoublyLinkedList) {
intern->std.handlers = &spl_handler_SplDoublyLinkedList;
break;
}
parent = parent->parent;
inherited = 1;
}
if (!parent) { /* this must never happen */
php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplDoublyLinkedList");
}
if (inherited) {
intern->fptr_offset_get = zend_hash_str_find_ptr(&class_type->function_table, "offsetget", sizeof("offsetget") - 1);
if (intern->fptr_offset_get->common.scope == parent) {
intern->fptr_offset_get = NULL;
}
intern->fptr_offset_set = zend_hash_str_find_ptr(&class_type->function_table, "offsetset", sizeof("offsetset") - 1);
if (intern->fptr_offset_set->common.scope == parent) {
intern->fptr_offset_set = NULL;
}
intern->fptr_offset_has = zend_hash_str_find_ptr(&class_type->function_table, "offsetexists", sizeof("offsetexists") - 1);
if (intern->fptr_offset_has->common.scope == parent) {
intern->fptr_offset_has = NULL;
}
intern->fptr_offset_del = zend_hash_str_find_ptr(&class_type->function_table, "offsetunset", sizeof("offsetunset") - 1);
if (intern->fptr_offset_del->common.scope == parent) {
intern->fptr_offset_del = NULL;
}
intern->fptr_count = zend_hash_str_find_ptr(&class_type->function_table, "count", sizeof("count") - 1);
if (intern->fptr_count->common.scope == parent) {
intern->fptr_count = NULL;
}
}
return &intern->std;
}
示例5: ftp_getdata
/* {{{ ftp_getdata
*/
databuf_t*
ftp_getdata(ftpbuf_t *ftp)
{
int fd = -1;
databuf_t *data;
php_sockaddr_storage addr;
struct sockaddr *sa;
socklen_t size;
union ipbox ipbox;
char arg[sizeof("255, 255, 255, 255, 255, 255")];
struct timeval tv;
/* ask for a passive connection if we need one */
if (ftp->pasv && !ftp_pasv(ftp, 1)) {
return NULL;
}
/* alloc the data structure */
data = ecalloc(1, sizeof(*data));
data->listener = -1;
data->fd = -1;
data->type = ftp->type;
sa = (struct sockaddr *) &ftp->localaddr;
/* bind/listen */
if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) == SOCK_ERR) {
php_error_docref(NULL, E_WARNING, "socket() failed: %s (%d)", strerror(errno), errno);
goto bail;
}
/* passive connection handler */
if (ftp->pasv) {
/* clear the ready status */
ftp->pasv = 1;
/* connect */
/* Win 95/98 seems not to like size > sizeof(sockaddr_in) */
size = php_sockaddr_size(&ftp->pasvaddr);
tv.tv_sec = ftp->timeout_sec;
tv.tv_usec = 0;
if (php_connect_nonb(fd, (struct sockaddr*) &ftp->pasvaddr, size, &tv) == -1) {
php_error_docref(NULL, E_WARNING, "php_connect_nonb() failed: %s (%d)", strerror(errno), errno);
goto bail;
}
data->fd = fd;
ftp->data = data;
return data;
}
/* active (normal) connection */
/* bind to a local address */
php_any_addr(sa->sa_family, &addr, 0);
size = php_sockaddr_size(&addr);
if (bind(fd, (struct sockaddr*) &addr, size) != 0) {
php_error_docref(NULL, E_WARNING, "bind() failed: %s (%d)", strerror(errno), errno);
goto bail;
}
if (getsockname(fd, (struct sockaddr*) &addr, &size) != 0) {
php_error_docref(NULL, E_WARNING, "getsockname() failed: %s (%d)", strerror(errno), errno);
goto bail;
}
if (listen(fd, 5) != 0) {
php_error_docref(NULL, E_WARNING, "listen() failed: %s (%d)", strerror(errno), errno);
goto bail;
}
data->listener = fd;
#if HAVE_IPV6 && HAVE_INET_NTOP
if (sa->sa_family == AF_INET6) {
/* need to use EPRT */
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];
char out[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out));
snprintf(eprtarg, sizeof(eprtarg), "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port));
if (!ftp_putcmd(ftp, "EPRT", eprtarg)) {
goto bail;
}
if (!ftp_getresp(ftp) || ftp->resp != 200) {
goto bail;
}
ftp->data = data;
return data;
}
#endif
/* send the PORT */
ipbox.ia[0] = ((struct sockaddr_in*) sa)->sin_addr;
//.........这里部分代码省略.........
示例6: ecalloc
/* {{{ php_url_parse
*/
PHPAPI php_url *php_url_parse_ex(char const *str, size_t length)
{
char port_buf[6];
php_url *ret = ecalloc(1, sizeof(php_url));
char const *s, *e, *p, *pp, *ue;
s = str;
ue = s + length;
/* parse scheme */
if ((e = memchr(s, ':', length)) && e != s) {
/* validate scheme */
p = s;
while (p < e) {
/* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */
if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *p != '-') {
if (e + 1 < ue && e < s + strcspn(s, "?#")) {
goto parse_port;
} else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
e = 0;
goto parse_host;
} else {
goto just_path;
}
}
p++;
}
if (e + 1 == ue) { /* only scheme is available */
ret->scheme = zend_string_init(s, (e - s), 0);
php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme));
return ret;
}
/*
* certain schemas like mailto: and zlib: may not have any / after them
* this check ensures we support those.
*/
if (*(e+1) != '/') {
/* check if the data we get is a port this allows us to
* correctly parse things like a.com:80
*/
p = e + 1;
while (p < ue && isdigit(*p)) {
p++;
}
if ((p == ue || *p == '/') && (p - e) < 7) {
goto parse_port;
}
ret->scheme = zend_string_init(s, (e-s), 0);
php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme));
s = e + 1;
goto just_path;
} else {
ret->scheme = zend_string_init(s, (e-s), 0);
php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme));
if (e + 2 < ue && *(e + 2) == '/') {
s = e + 3;
if (zend_string_equals_literal_ci(ret->scheme, "file")) {
if (e + 3 < ue && *(e + 3) == '/') {
/* support windows drive letters as in:
file:///c:/somedir/file.txt
*/
if (e + 5 < ue && *(e + 5) == ':') {
s = e + 4;
}
goto just_path;
}
}
} else {
s = e + 1;
goto just_path;
}
}
} else if (e) { /* no scheme; starts with colon: look for port */
parse_port:
p = e + 1;
pp = p;
while (pp < ue && pp - p < 6 && isdigit(*pp)) {
pp++;
}
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/')) {
zend_long port;
memcpy(port_buf, p, (pp - p));
port_buf[pp - p] = '\0';
port = ZEND_STRTOL(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
ret->port = (unsigned short) port;
if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
}
//.........这里部分代码省略.........
示例7: pw2entry
static struct ldentry *
pw2entry( struct ldop *op, struct passwd *pw )
{
struct ldentry *entry;
struct ldattr *attr;
int i;
entry = (struct ldentry *) ecalloc( 1, sizeof( struct ldentry ));
/*
* construct the DN from pw_name
*/
if ( strchr( op->ldop_suffixes[ 0 ], '=' ) != NULL ) {
/*
* X.500 style DN
*/
sprintf( tmpbuf, "cn=%s, %s", pw->pw_name, op->ldop_suffixes[ 0 ] );
} else {
/*
* RFC-822 style DN
*/
sprintf( tmpbuf, "%[email protected]%s", pw->pw_name, op->ldop_suffixes[ 0 ] );
}
entry->lde_dn = estrdup( tmpbuf );
/*
* for now, we simply derive the LDAP attribute values as follows:
* objectClass = person
* uid = pw_name
* sn = pw_name
* cn = pw_name
* cn = pw_gecos (second common name)
*/
entry->lde_attrs = (struct ldattr **)ecalloc( 5, sizeof( struct ldattr * ));
i = 0;
attr = (struct ldattr *)ecalloc( 1, sizeof( struct ldattr ));
attr->lda_name = estrdup( "objectClass" );
attr->lda_values = (char **)ecalloc( 2, sizeof( char * ));
attr->lda_values[ 0 ] = estrdup( "person" );
entry->lde_attrs[ i++ ] = attr;
attr = (struct ldattr *)ecalloc( 1, sizeof( struct ldattr ));
attr->lda_name = estrdup( "uid" );
attr->lda_values = (char **)ecalloc( 2, sizeof( char * ));
attr->lda_values[ 0 ] = estrdup( pw->pw_name );
entry->lde_attrs[ i++ ] = attr;
attr = (struct ldattr *)ecalloc( 1, sizeof( struct ldattr ));
attr->lda_name = estrdup( "sn" );
attr->lda_values = (char **)ecalloc( 2, sizeof( char * ));
attr->lda_values[ 0 ] = estrdup( pw->pw_name );
entry->lde_attrs[ i++ ] = attr;
attr = (struct ldattr *)ecalloc( 1, sizeof( struct ldattr ));
attr->lda_name = estrdup( "cn" );
attr->lda_values = (char **)ecalloc( 3, sizeof( char * ));
attr->lda_values[ 0 ] = estrdup( pw->pw_name );
if ( pw->pw_gecos != NULL && *pw->pw_gecos != '\0' ) {
attr->lda_values[ 1 ] = estrdup( pw->pw_gecos );
}
entry->lde_attrs[ i++ ] = attr;
return( entry );
}
示例8: zend_update_property_double
void zend_update_property_double(zend_class_entry *scope, zval *object, char *name, int name_length, double value TSRMLS_DC)
{
zval *tmp = ecalloc(1, sizeof(zval));
ZVAL_DOUBLE(tmp, value);
zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
}
示例9: zend_update_property_bool
void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC)
{
zval *tmp = ecalloc(1, sizeof(zval));
ZVAL_BOOL(tmp, value);
zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);
}
示例10: oks_build_context
/**
* Populate an observe collection with the appropriate key contexts
* @param res the couchbase object
* @param ocoll an already allocated collection object
* @param akc a zend array mapping keys to their expected CAS values
* @param expectation an array of durability requirements
* @param append_prefix - whether the keys should be appended with the
* couchbase-level prefix
*/
static int oks_build_context(php_couchbase_res *res,
struct observe_collection *ocoll,
struct observe_expectation *expectation,
zval *akc,
int append_prefix)
{
int nks, ix;
struct observe_keystate *ks;
nks = pcbc_ht_len(akc);
ks = ecalloc(sizeof(*ks), nks);
for (ix = 0, pcbc_ht_iter_init(akc);
pcbc_ht_iter_remaining(akc);
pcbc_ht_iter_next(akc), ix++) {
pcbc_ht_entry *kv = pcbc_ht_iter_entry(akc);
struct observe_keystate *oks = ks + ix;
if (kv->key_info->key_len == 0) {
ix--;
continue;
}
oks->parent = ocoll;
if (expectation) {
oks->expected = *expectation;
}
if ((oks->expected.cas = cas_from_zval(kv->data)) == -1) {
pcbc_ht_entry_free(kv);
goto GT_CLEANUP;
}
if (append_prefix && res->prefix_key_len &&
ocoll->prefix_appended == 0) {
pcbc_ht_key prefixed_ki;
make_prefixed_hk(res, kv->key_info->key, kv->key_info->key_len,
&prefixed_ki);
oks->ocmd.v.v0.nkey = prefixed_ki.key_len;
oks->ocmd.v.v0.key = emalloc(prefixed_ki.key_len);
memcpy((char *)oks->ocmd.v.v0.key,
prefixed_ki.key,
prefixed_ki.key_len);
pcbc_ht_key_cleanup(&prefixed_ki);
} else {
oks->ocmd.v.v0.key = emalloc(kv->key_info->key_len);
oks->ocmd.v.v0.nkey = kv->key_info->key_len;
memcpy((char *)oks->ocmd.v.v0.key,
kv->key_info->key,
oks->ocmd.v.v0.nkey);
}
pcbc_ht_entry_free(kv);
if (append_prefix && res->prefix_key_len) {
ocoll->prefix_appended = 1;
}
}
ocoll->ks = ks;
ocoll->nks = ix;
ocoll->remaining = ocoll->nks;
ocoll->res = res;
return 0;
GT_CLEANUP:
for (ix = 0; ix < nks; ix++) {
struct observe_keystate *oks = ks + ix;
if (oks->ocmd.v.v0.key) {
efree((void *) oks->ocmd.v.v0.key);
}
}
efree(ks);
return -1;
}
示例11: ecalloc
static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) /* {{{ */
{
spl_fixedarray_object *intern;
zend_class_entry *parent = class_type;
int inherited = 0;
intern = ecalloc(1, sizeof(spl_fixedarray_object) + zend_object_properties_size(parent));
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
intern->current = 0;
intern->flags = 0;
if (orig && clone_orig) {
spl_fixedarray_object *other = Z_SPLFIXEDARRAY_P(orig);
intern->ce_get_iterator = other->ce_get_iterator;
spl_fixedarray_init(&intern->array, other->array.size);
spl_fixedarray_copy(&intern->array, &other->array);
}
while (parent) {
if (parent == spl_ce_SplFixedArray) {
intern->std.handlers = &spl_handler_SplFixedArray;
class_type->get_iterator = spl_fixedarray_get_iterator;
break;
}
parent = parent->parent;
inherited = 1;
}
if (!parent) { /* this must never happen */
php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplFixedArray");
}
if (!class_type->iterator_funcs.zf_current) {
class_type->iterator_funcs.zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
class_type->iterator_funcs.zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
class_type->iterator_funcs.zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
class_type->iterator_funcs.zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
class_type->iterator_funcs.zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
}
if (inherited) {
if (class_type->iterator_funcs.zf_rewind->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_REWIND;
}
if (class_type->iterator_funcs.zf_valid->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_VALID;
}
if (class_type->iterator_funcs.zf_key->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_KEY;
}
if (class_type->iterator_funcs.zf_current->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_CURRENT;
}
if (class_type->iterator_funcs.zf_next->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_NEXT;
}
intern->fptr_offset_get = zend_hash_str_find_ptr(&class_type->function_table, "offsetget", sizeof("offsetget") - 1);
if (intern->fptr_offset_get->common.scope == parent) {
intern->fptr_offset_get = NULL;
}
intern->fptr_offset_set = zend_hash_str_find_ptr(&class_type->function_table, "offsetset", sizeof("offsetset") - 1);
if (intern->fptr_offset_set->common.scope == parent) {
intern->fptr_offset_set = NULL;
}
intern->fptr_offset_has = zend_hash_str_find_ptr(&class_type->function_table, "offsetexists", sizeof("offsetexists") - 1);
if (intern->fptr_offset_has->common.scope == parent) {
intern->fptr_offset_has = NULL;
}
intern->fptr_offset_del = zend_hash_str_find_ptr(&class_type->function_table, "offsetunset", sizeof("offsetunset") - 1);
if (intern->fptr_offset_del->common.scope == parent) {
intern->fptr_offset_del = NULL;
}
intern->fptr_count = zend_hash_str_find_ptr(&class_type->function_table, "count", sizeof("count") - 1);
if (intern->fptr_count->common.scope == parent) {
intern->fptr_count = NULL;
}
}
return &intern->std;
}
示例12: apc_iterator_item_ctor
/* {{{ apc_iterator_item */
static apc_iterator_item_t* apc_iterator_item_ctor(apc_iterator_t *iterator, slot_t **slot_pp) {
zval *zvalue;
char md5str[33];
slot_t *slot = *slot_pp;
apc_context_t ctxt = {0, };
apc_iterator_item_t *item = ecalloc(1, sizeof(apc_iterator_item_t));
if (slot->key.type == APC_CACHE_KEY_FILE) {
/* keys should be unique and with stat=1 we could have multiple files with the same name, so use '<device> <inode>' instead */
#ifdef PHP_WIN32
item->key_len = spprintf(&item->key, 0, "%I64d %I64d", slot->key.data.file.device, slot->key.data.file.inode);
#else
item->key_len = spprintf(&item->key, 0, "%ld %ld", (ulong)slot->key.data.file.device, (ulong)slot->key.data.file.inode);
#endif
item->filename_key = estrdup(slot->value->data.file.filename);
} else if (slot->key.type == APC_CACHE_KEY_USER) {
item->key = estrndup((char*)slot->key.data.user.identifier, slot->key.data.user.identifier_len);
item->key_len = slot->key.data.user.identifier_len;
item->filename_key = item->key;
} else if (slot->key.type == APC_CACHE_KEY_FPFILE) {
item->key = estrndup((char*)slot->key.data.fpfile.fullpath, slot->key.data.fpfile.fullpath_len);
item->key_len = slot->key.data.fpfile.fullpath_len;
} else {
apc_eprint("Internal error, invalid entry type.");
}
ALLOC_INIT_ZVAL(item->value);
array_init(item->value);
if (APC_ITER_TYPE & iterator->format) {
if(slot->value->type == APC_CACHE_ENTRY_FILE) {
add_assoc_string(item->value, "type", "file", 1);
} else if(slot->value->type == APC_CACHE_ENTRY_USER) {
add_assoc_string(item->value, "type", "user", 1);
}
}
if (APC_ITER_FILENAME & iterator->format) {
if(slot->value->type == APC_CACHE_ENTRY_FILE) {
if (slot->key.type == APC_CACHE_KEY_FILE) {
add_assoc_string(item->value, "filename", slot->value->data.file.filename, 1);
} else { /* APC_CACHE_FPFILE */
add_assoc_string(item->value, "filename", (char*)slot->key.data.fpfile.fullpath, 1);
}
}
}
if (APC_ITER_DEVICE & iterator->format) {
if(slot->key.type == APC_CACHE_KEY_FILE) {
#ifdef PHP_WIN32
char buf[20];
sprintf(buf, "%I64d", slot->key.data.file.device);
add_assoc_string(item->value, "device", buf, 1);
#else
add_assoc_long(item->value, "device", slot->key.data.file.device);
#endif
}
}
if (APC_ITER_INODE & iterator->format) {
if(slot->key.type == APC_CACHE_KEY_FILE) {
#ifdef PHP_WIN32
char buf[20];
sprintf(buf, "%I64d", slot->key.data.file.device);
add_assoc_string(item->value, "device", buf, 1);
#else
add_assoc_long(item->value, "inode", slot->key.data.file.inode);
#endif
}
}
if (APC_ITER_KEY & iterator->format) {
add_assoc_stringl(item->value, "key", item->key, item->key_len, 1);
}
if (APC_ITER_VALUE & iterator->format) {
if(slot->value->type == APC_CACHE_ENTRY_USER) {
ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL);
ctxt.copy = APC_COPY_OUT_USER;
MAKE_STD_ZVAL(zvalue);
apc_cache_fetch_zval(zvalue, slot->value->data.user.val, &ctxt);
apc_pool_destroy(ctxt.pool);
add_assoc_zval(item->value, "value", zvalue);
}
}
if (APC_ITER_MD5 & iterator->format) {
if(slot->value->type == APC_CACHE_ENTRY_FILE) {
if(slot->key.md5) {
make_digest(md5str, slot->key.md5);
add_assoc_string(item->value, "md5", md5str, 1);
}
}
}
if (APC_ITER_NUM_HITS & iterator->format) {
add_assoc_long(item->value, "num_hits", slot->num_hits);
}
if (APC_ITER_MTIME & iterator->format) {
add_assoc_long(item->value, "mtime", slot->key.mtime);
}
if (APC_ITER_CTIME & iterator->format) {
add_assoc_long(item->value, "creation_time", slot->creation_time);
}
//.........这里部分代码省略.........
示例13: oci_stmt_param_hook
static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type) /* {{{ */
{
pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
/* we're only interested in parameters for prepared SQL right now */
if (param->is_param) {
pdo_oci_bound_param *P;
sb4 value_sz = -1;
P = (pdo_oci_bound_param*)param->driver_data;
switch (event_type) {
case PDO_PARAM_EVT_FETCH_PRE:
case PDO_PARAM_EVT_FETCH_POST:
case PDO_PARAM_EVT_NORMALIZE:
/* Do nothing */
break;
case PDO_PARAM_EVT_FREE:
P = param->driver_data;
if (P) {
efree(P);
}
break;
case PDO_PARAM_EVT_ALLOC:
P = (pdo_oci_bound_param*)ecalloc(1, sizeof(pdo_oci_bound_param));
param->driver_data = P;
/* figure out what we're doing */
switch (PDO_PARAM_TYPE(param->param_type)) {
case PDO_PARAM_STMT:
return 0;
case PDO_PARAM_LOB:
/* P->thing is now an OCILobLocator * */
P->oci_type = SQLT_BLOB;
value_sz = sizeof(OCILobLocator*);
break;
case PDO_PARAM_STR:
default:
P->oci_type = SQLT_CHR;
value_sz = param->max_value_len;
if (param->max_value_len == 0) {
value_sz = 1332; /* maximum size before value is interpreted as a LONG value */
}
}
if (param->name) {
STMT_CALL(OCIBindByName, (S->stmt,
&P->bind, S->err, (text*)param->name,
param->namelen, 0, value_sz, P->oci_type,
&P->indicator, 0, &P->retcode, 0, 0,
OCI_DATA_AT_EXEC));
} else {
STMT_CALL(OCIBindByPos, (S->stmt,
&P->bind, S->err, param->paramno+1,
0, value_sz, P->oci_type,
&P->indicator, 0, &P->retcode, 0, 0,
OCI_DATA_AT_EXEC));
}
STMT_CALL(OCIBindDynamic, (P->bind,
S->err,
param, oci_bind_input_cb,
param, oci_bind_output_cb));
return 1;
case PDO_PARAM_EVT_EXEC_PRE:
P->indicator = 0;
P->used_for_output = 0;
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) {
ub4 empty = 0;
STMT_CALL(OCIDescriptorAlloc, (S->H->env, &P->thing, OCI_DTYPE_LOB, 0, NULL));
STMT_CALL(OCIAttrSet, (P->thing, OCI_DTYPE_LOB, &empty, 0, OCI_ATTR_LOBEMPTY, S->err));
S->have_blobs = 1;
}
return 1;
case PDO_PARAM_EVT_EXEC_POST:
/* fixup stuff set in motion in oci_bind_output_cb */
if (P->used_for_output) {
if (P->indicator == -1) {
/* set up a NULL value */
if (Z_TYPE_P(param->parameter) == IS_STRING
#if ZEND_EXTENSION_API_NO < 220040718
&& Z_STRVAL_P(param->parameter) != empty_string
#endif
) {
/* OCI likes to stick non-terminated strings in things */
*Z_STRVAL_P(param->parameter) = '\0';
}
zval_dtor(param->parameter);
ZVAL_NULL(param->parameter);
} else if (Z_TYPE_P(param->parameter) == IS_STRING
#if ZEND_EXTENSION_API_NO < 220040718
&& Z_STRVAL_P(param->parameter) != empty_string
//.........这里部分代码省略.........
示例14: oci_stmt_execute
static int oci_stmt_execute(pdo_stmt_t *stmt) /* {{{ */
{
pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
ub4 rowcount;
b4 mode;
if (!S->stmt_type) {
STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_STMT_TYPE",
(S->stmt, OCI_HTYPE_STMT, &S->stmt_type, 0, OCI_ATTR_STMT_TYPE, S->err));
}
if (stmt->executed) {
/* ensure that we cancel the cursor from a previous fetch */
OCIStmtFetch(S->stmt, S->err, 0, OCI_FETCH_NEXT, OCI_DEFAULT);
}
#ifdef OCI_STMT_SCROLLABLE_READONLY /* needed for oci8 ? */
if (S->exec_type == OCI_STMT_SCROLLABLE_READONLY) {
mode = OCI_STMT_SCROLLABLE_READONLY;
} else
#endif
if (stmt->dbh->auto_commit && !stmt->dbh->in_txn) {
mode = OCI_COMMIT_ON_SUCCESS;
} else {
mode = OCI_DEFAULT;
}
STMT_CALL(OCIStmtExecute, (S->H->svc, S->stmt, S->err,
(S->stmt_type == OCI_STMT_SELECT && !S->have_blobs) ? 0 : 1, 0, NULL, NULL,
mode));
if (!stmt->executed) {
ub4 colcount;
/* do first-time-only definition of bind/mapping stuff */
/* how many columns do we have ? */
STMT_CALL_MSG(OCIAttrGet, "ATTR_PARAM_COUNT",
(S->stmt, OCI_HTYPE_STMT, &colcount, 0, OCI_ATTR_PARAM_COUNT, S->err));
stmt->column_count = (int)colcount;
if (S->cols) {
int i;
for (i = 0; i < stmt->column_count; i++) {
if (S->cols[i].data) {
switch (S->cols[i].dtype) {
case SQLT_BLOB:
case SQLT_CLOB:
/* do nothing */
break;
default:
efree(S->cols[i].data);
}
}
}
efree(S->cols);
}
S->cols = ecalloc(colcount, sizeof(pdo_oci_column));
}
STMT_CALL_MSG(OCIAttrGet, "ATTR_ROW_COUNT",
(S->stmt, OCI_HTYPE_STMT, &rowcount, 0, OCI_ATTR_ROW_COUNT, S->err));
stmt->row_count = (long)rowcount;
return 1;
} /* }}} */
示例15: php_couchbase_get_delayed_impl
PHP_COUCHBASE_LOCAL
void php_couchbase_get_delayed_impl(INTERNAL_FUNCTION_PARAMETERS, int oo) /* {{{ */
{
zval *res, *akeys;
long with_cas = 0;
lcb_time_t exp = {0};
long expiry = 0;
zend_bool lock = 0;
int argflags = PHP_COUCHBASE_ARG_F_ASYNC;
php_couchbase_res *couchbase_res;
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 2
zend_fcall_info fci = {0};
zend_fcall_info_cache fci_cache = {0};
if (oo) {
argflags |= PHP_COUCHBASE_ARG_F_OO;
} else {
argflags |= PHP_COUCHBASE_ARG_F_FUNCTIONAL;
}
PHP_COUCHBASE_GET_PARAMS_WITH_ZV(res, couchbase_res, argflags,
"a|lf!lb",
&akeys, &with_cas, &fci, &fci_cache, &expiry, &lock);
#else
if (oo) {
argflags |= PHP_COUCHBASE_ARG_F_OO;
} else {
argflags |= PHP_COUCHBASE_ARG_F_FUNCTIONAL;
}
zval *callback = NULL;
PHP_COUCHBASE_GET_PARAMS_WITH_ZV(res, couchbase_res, argflags,
"a|lzlb", &akeys, &with_cas, &callback, &expiry, &lock);
if (callback && Z_TYPE_P(callback) != IS_NULL
&& !zend_is_callable(callback, 0, NULL)) {
couchbase_report_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, oo,
cb_exception,
"third argument is expected to be a valid callback");
return;
}
#endif
{
zval **ppzval;
lcb_error_t retval;
php_couchbase_ctx *ctx;
char **keys;
long nkey, *klens, i;
nkey = zend_hash_num_elements(Z_ARRVAL_P(akeys));
keys = ecalloc(nkey, sizeof(char *));
klens = ecalloc(nkey, sizeof(long));
for (i = 0, zend_hash_internal_pointer_reset(Z_ARRVAL_P(akeys));
zend_hash_has_more_elements(Z_ARRVAL_P(akeys)) == SUCCESS;
zend_hash_move_forward(Z_ARRVAL_P(akeys)), i++) {
if (zend_hash_get_current_data(Z_ARRVAL_P(akeys), (void **)&ppzval) == FAILURE) {
nkey--;
continue;
}
if (IS_ARRAY != Z_TYPE_PP(ppzval)) {
convert_to_string_ex(ppzval);
}
if (!Z_STRLEN_PP(ppzval)) {
nkey--;
continue;
}
if (couchbase_res->prefix_key_len) {
klens[i] = spprintf(&(keys[i]), 0, "%s_%s", couchbase_res->prefix_key, Z_STRVAL_PP(ppzval));
} else {
keys[i] = Z_STRVAL_PP(ppzval);
klens[i] = Z_STRLEN_PP(ppzval);
}
}
if (!nkey) {
efree(keys);
efree(klens);
return;
}
couchbase_res->seqno += nkey;
ctx = ecalloc(1, sizeof(php_couchbase_ctx));
ctx->res = couchbase_res;
ctx->flags = with_cas;
{
lcb_get_cmd_t **commands = ecalloc(nkey, sizeof(lcb_get_cmd_t *));
int ii;
if (expiry) {
exp = pcbc_check_expiry(expiry);
}
//.........这里部分代码省略.........