本文整理汇总了C++中pemalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ pemalloc函数的具体用法?C++ pemalloc怎么用?C++ pemalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pemalloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WideCharToMultiByte
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage)
{
char *C_str;
uint length = 0;
//request needed buffersize
uint reqSize = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL);
if(reqSize)
{
C_str = (char *) pemalloc(sizeof(char) * reqSize, persistent);
//convert string
length = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1;
}
else
{
C_str = (char *) pemalloc(sizeof(char), persistent);
*C_str = 0;
php_error(E_WARNING,"Error in php_OLECHAR_to_char()");
}
if(out_length)
*out_length = length;
return C_str;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:28,代码来源:conversion.c
示例2: browscap_read_file
static int browscap_read_file(char *filename, browser_data *browdata, int persistent) /* {{{ */
{
zend_file_handle fh;
browscap_parser_ctx ctx = {0};
if (filename == NULL || filename[0] == '\0') {
return FAILURE;
}
fh.handle.fp = VCWD_FOPEN(filename, "r");
fh.opened_path = NULL;
fh.free_filename = 0;
if (!fh.handle.fp) {
zend_error(E_CORE_WARNING, "Cannot open '%s' for reading", filename);
return FAILURE;
}
fh.filename = filename;
fh.type = ZEND_HANDLE_FP;
browdata->htab = pemalloc(sizeof *browdata->htab, persistent);
if (browdata->htab == NULL) {
return FAILURE;
}
zend_hash_init_ex(browdata->htab, 0, NULL,
persistent ? browscap_entry_dtor_persistent : browscap_entry_dtor, persistent, 0);
browdata->kv_size = 16 * 1024;
browdata->kv_used = 0;
browdata->kv = pemalloc(sizeof(browscap_kv) * browdata->kv_size, persistent);
/* Create parser context */
ctx.bdata = browdata;
ctx.current_entry = NULL;
ctx.current_section_name = NULL;
ctx.str_empty = zend_string_init("", sizeof("")-1, persistent);
ctx.str_one = zend_string_init("1", sizeof("1")-1, persistent);
zend_hash_init(&ctx.str_interned, 8, NULL, NULL, persistent);
zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_RAW,
(zend_ini_parser_cb_t) php_browscap_parser_cb, &ctx);
/* Destroy parser context */
if (ctx.current_section_name) {
zend_string_release(ctx.current_section_name);
}
zend_string_release(ctx.str_one);
zend_string_release(ctx.str_empty);
zend_hash_destroy(&ctx.str_interned);
return SUCCESS;
}
开发者ID:Synchro,项目名称:php-src,代码行数:53,代码来源:browscap.c
示例3: PHP_METHOD
/* {{{ proto bool SolrInputDocument::addField(string field_name, field_value [, float field_boost])
Adds a field to the document. Can be called multiple times. */
PHP_METHOD(SolrInputDocument, addField)
{
solr_char_t *field_name = NULL, *field_value = NULL;
COMPAT_ARG_SIZE_T field_name_length = 0, field_value_length = 0;
solr_document_t *doc_entry = NULL;
double field_boost = 0.0;
/* Process the parameters passed to the method */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|d", &field_name,
&field_name_length, &field_value, &field_value_length, &field_boost) == FAILURE) {
RETURN_FALSE;
}
if (!field_name_length) {
RETURN_FALSE;
}
/* Retrieve the document entry for the SolrDocument instance */
if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS)
{
solr_field_list_t *field_values = NULL;
/* If the field already exists in the SolrDocument instance append the value to the field list queue */
if ((field_values = (solr_field_list_t *)zend_hash_str_find_ptr(doc_entry->fields, field_name, field_name_length)) != NULL) {
if (solr_document_insert_field_value(field_values, (solr_char_t *)field_value, field_boost) == FAILURE) {
RETURN_FALSE;
}
} else {
/* Otherwise, create a new one and add it to the hash table */
field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT);
memset(field_values, 0, sizeof(solr_field_list_t));
field_values->count = 0L;
field_values->field_boost = 0.0;
field_values->field_name = (solr_char_t *) pestrdup((char *)field_name, SOLR_DOCUMENT_FIELD_PERSISTENT);
field_values->head = NULL;
field_values->last = NULL;
if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) {
solr_destroy_field_list(field_values);
RETURN_FALSE;
}
if (zend_hash_str_add_ptr(doc_entry->fields, field_name, field_name_length,(void *) field_values) == NULL) {
solr_destroy_field_list(field_values);
RETURN_FALSE;
}
/* Increment field count only when HEAD is added */
doc_entry->field_count++;
}
RETURN_TRUE;
}
RETURN_FALSE;
}
开发者ID:cfgxy,项目名称:php-solr,代码行数:62,代码来源:php_solr_input_document.c
示例4: exec_php
/**
* Gets the contents of the BLOB b and offers it to Zend for parsing/execution
*/
void exec_php(BLOBCALLBACK b, PARAMDSC *res, ISC_SHORT *init)
{
int result, remaining = b->blob_total_length, i = 0;
char *code = pemalloc(remaining+1, 1);
ISC_USHORT read;
for (code[remaining] = '\0'; remaining > 0; remaining -= read)
b->blob_get_segment(b->blob_handle, &code[i++<<16],min(0x10000,remaining), &read);
LOCK();
switch (init && *init) {
default:
#ifdef PHP_EMBED
php_request_shutdown(NULL);
if (FAILURE == (result = php_request_startup(TSRMLS_C))) {
break;
}
case 0:
#endif
/* feed it to the parser */
zend_first_try {
result = zend_eval_stringl(code, b->blob_total_length, NULL, "Firebird Embedded PHP engine" TSRMLS_CC);
} zend_end_try();
}
UNLOCK();
free(code);
res->dsc_dtype = dtype_long;
*(ISC_LONG*)res->dsc_address = (result == SUCCESS);
}
开发者ID:1HLtd,项目名称:php-src,代码行数:37,代码来源:php_ibase_udf.c
示例5: gir_enum_constant_name
/**
* Helpers for sticking items into the Gir namespace
*/
char* gir_enum_constant_name(const char *ns_name, const char *constant, const char *name, zend_bool persistent)
{
char *phpname = pemalloc(4 + strlen(ns_name) + strlen(constant) + strlen(name) + 2, persistent);
sprintf(phpname, "Gir\\%s\\%s\\%s", ns_name, name, constant);
return phpname;
}
开发者ID:gtkforphp,项目名称:gintrospection,代码行数:10,代码来源:types.c
示例6: find
/* get the curl item of the key */
static CURL* find(char *key, uint key_len) {
uint i;
curl_item *item;
for (i=0; i<ITEM_MAX; i++) {
item = items[i];
if (item == NULL) {
item = pemalloc(sizeof(curl_item), 1);
item->key = key;
item->key_len = key_len;
item->curl = curl_easy_init();
if (item->curl != NULL) {
curl_easy_setopt(item->curl, CURLOPT_HEADER, 0);
curl_easy_setopt(item->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
items[i] = item;
return item->curl;
}
return NULL;
}
if (item->key_len == key_len && (strcmp(item->key, key) == 0)) {
return item->curl;
}
}
return replace(key, key_len);
}
开发者ID:shinezhou,项目名称:http,代码行数:26,代码来源:http.c
示例7: MAKE_PZVAL_STR
/**
* This function allocates a persistent zval and copy the string with pestrndup (persistent).
*/
void MAKE_PZVAL_STR(zval** zdata, zval * zstr)
{
*zdata = pemalloc(sizeof(zval), 1);
Z_TYPE_PP(zdata) = Z_TYPE_P(zstr);
Z_STRVAL_PP(zdata) = pestrndup(Z_STRVAL_P(zstr), Z_STRLEN_P(zstr), 1);
Z_STRLEN_PP(zdata) = Z_STRLEN_P(zstr);
}
开发者ID:c9s,项目名称:php-r3,代码行数:10,代码来源:php_r3.c
示例8: zend_ptr_stack_init_ex
ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent) /* {{{ */
{
stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent);
stack->max = PTR_STACK_BLOCK_SIZE;
stack->top = 0;
stack->persistent = persistent;
}
开发者ID:browniebraun,项目名称:php-src,代码行数:7,代码来源:zend_ptr_stack.c
示例9: _mysqlnd_pemalloc
/* {{{ _mysqlnd_pemalloc */
void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
{
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
#endif
DBG_ENTER(mysqlnd_pemalloc_name);
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
#if PHP_DEBUG
/* -1 is also "true" */
if (*threshold) {
#endif
ret = pemalloc(REAL_SIZE(size), persistent);
#if PHP_DEBUG
--*threshold;
} else if (*threshold == 0) {
ret = NULL;
}
#endif
DBG_INF_FMT("size=%lu ptr=%p persistent=%u", size, ret, persistent);
if (ret && collect_memory_statistics) {
enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_MALLOC_COUNT:STAT_MEM_EMALLOC_COUNT;
enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_MALLOC_AMOUNT:STAT_MEM_EMALLOC_AMOUNT;
*(size_t *) ret = size;
MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, size);
}
DBG_RETURN(FAKE_PTR(ret));
}
开发者ID:Doap,项目名称:php-src,代码行数:34,代码来源:mysqlnd_alloc.c
示例10: zend_interned_strings_init
ZEND_API void zend_interned_strings_init(void)
{
char s[2];
int i;
zend_string *str;
zend_init_interned_strings_ht(&interned_strings_permanent, 1);
zend_new_interned_string = zend_new_interned_string_permanent;
zend_string_init_interned = zend_string_init_interned_permanent;
/* interned empty string */
str = zend_string_alloc(sizeof("")-1, 1);
ZSTR_VAL(str)[0] = '\000';
zend_empty_string = zend_new_interned_string_permanent(str);
s[1] = 0;
for (i = 0; i < 256; i++) {
s[0] = i;
zend_one_char_string[i] = zend_new_interned_string_permanent(zend_string_init(s, 1, 1));
}
/* known strings */
zend_known_strings = pemalloc(sizeof(zend_string*) * ((sizeof(known_strings) / sizeof(known_strings[0]) - 1)), 1);
for (i = 0; i < (sizeof(known_strings) / sizeof(known_strings[0])) - 1; i++) {
str = zend_string_init(known_strings[i], strlen(known_strings[i]), 1);
zend_known_strings[i] = zend_new_interned_string_permanent(str);
}
}
开发者ID:eaglewu,项目名称:php-src,代码行数:29,代码来源:zend_string.c
示例11: field_copy_constructor
/* {{{ void field_copy_constructor(solr_field_list_t **original_field_queue) */
PHP_SOLR_API void field_copy_constructor(solr_field_list_t **original_field_queue)
{
solr_field_list_t *new_field_queue = NULL;
solr_field_value_t *ptr = (*original_field_queue)->head;
if (ptr == NULL)
{
return;
}
new_field_queue = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT);
new_field_queue->count = 0L;
new_field_queue->field_name = (solr_char_t *) pestrdup((char *) (*original_field_queue)->field_name, SOLR_DOCUMENT_FIELD_PERSISTENT);
new_field_queue->head = NULL;
new_field_queue->last = NULL;
new_field_queue->field_boost = (*original_field_queue)->field_boost;
while(ptr != NULL)
{
solr_document_insert_field_value(new_field_queue, ptr->field_value, 0);
ptr = ptr->next;
}
*original_field_queue = new_field_queue;
}
开发者ID:erning,项目名称:php-pecl-solr,代码行数:28,代码来源:solr_functions_document.c
示例12: lsapi_activate_user_ini_mk_user_config
static int lsapi_activate_user_ini_mk_user_config(_lsapi_activate_user_ini_ctx *ctx,
void* next)
{
fn_activate_user_ini_chain_t *fn_next = next;
/* Find cached config entry: If not found, create one */
ctx->entry = zend_hash_str_find_ptr(&user_config_cache, ctx->path, ctx->path_len);
if (ctx->entry) {
DEBUG_MESSAGE("found entry for %s", ctx->path);
} else {
DEBUG_MESSAGE("entry for %s not found, creating new entry", ctx->path);
ctx->entry = pemalloc(sizeof(user_config_cache_entry), 1);
ctx->entry->expires = 0;
zend_hash_init(&ctx->entry->user_config, 0, NULL,
config_zval_dtor, 1);
zend_hash_str_update_ptr(&user_config_cache, ctx->path,
ctx->path_len, ctx->entry);
}
if (*fn_next) {
return (*fn_next)(ctx, fn_next + 1);
} else {
return SUCCESS;
}
}
开发者ID:RyanNerd,项目名称:php-src,代码行数:26,代码来源:lsapi_main.c
示例13: zend_declare_property_bool
int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC)
{
zval *property = pemalloc(sizeof(zval), ce->type & ZEND_INTERNAL_CLASS);
INIT_PZVAL(property);
ZVAL_BOOL(property, value);
return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC);
}
开发者ID:ngourdeau,项目名称:pecl-http,代码行数:7,代码来源:missing.c
示例14: function_copy_ctor
static void function_copy_ctor(zval *zv) /* {{{ */
{
zend_function *old_func = Z_FUNC_P(zv);
Z_FUNC_P(zv) = pemalloc(sizeof(zend_internal_function), 1);
memcpy(Z_FUNC_P(zv), old_func, sizeof(zend_internal_function));
function_add_ref(Z_FUNC_P(zv));
}
开发者ID:LuthandoE,项目名称:php-src,代码行数:7,代码来源:zend.c
示例15: PHP_INI_MH
static PHP_INI_MH(OnChangeCallback) /* {{{ */
{
if (EG(in_execution)) {
if (ASSERTG(callback)) {
zval_ptr_dtor(&ASSERTG(callback));
ASSERTG(callback) = NULL;
}
if (new_value && (ASSERTG(callback) || new_value_length)) {
MAKE_STD_ZVAL(ASSERTG(callback));
ZVAL_STRINGL(ASSERTG(callback), new_value, new_value_length, 1);
}
} else {
if (ASSERTG(cb)) {
pefree(ASSERTG(cb), 1);
}
if (new_value && new_value_length) {
ASSERTG(cb) = pemalloc(new_value_length + 1, 1);
memcpy(ASSERTG(cb), new_value, new_value_length);
ASSERTG(cb)[new_value_length] = '\0';
} else {
ASSERTG(cb) = NULL;
}
}
return SUCCESS;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:25,代码来源:assert.c
示例16: pemalloc
void *riack_php_persistent_alloc(void *ptr, size_t size)/* {{{ */
{
if (size == 0) {
return 0;
}
return pemalloc(size, 1);
}
开发者ID:mickelfeng,项目名称:php_riak,代码行数:8,代码来源:php_riak.c
示例17: memcached_get_user_data
static
void *s_pemalloc_fn(const memcached_st *memc, size_t size, void *context)
{
zend_bool *is_persistent = memcached_get_user_data(memc);
return
pemalloc(size, *is_persistent);
}
开发者ID:TysonAndre,项目名称:php-memcached,代码行数:8,代码来源:php_memcached_session.c
示例18: solr_document_insert_field_value
/* {{{ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost) */
PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost)
{
solr_field_value_t *new_entry = (solr_field_value_t *) pemalloc(sizeof(solr_field_value_t), SOLR_DOCUMENT_FIELD_PERSISTENT);
if (new_entry == NULL) {
return FAILURE;
}
new_entry->field_value = (solr_char_t *) pestrdup((char *) field_value, SOLR_DOCUMENT_FIELD_PERSISTENT);
if (new_entry->field_value == NULL) {
return FAILURE;
}
new_entry->next = NULL;
if (queue->head == NULL) {
/* This is the first and only item in the field list */
queue->head = new_entry;
queue->last = new_entry;
/* Update the field boost value */
if (field_boost > 0.0) {
queue->field_boost = field_boost;
}
} else { /* There are already entries in the list. */
/* Append to the end of the queue */
queue->last->next = new_entry;
/* Set the last item in the queue to the latest entry */
queue->last = new_entry;
/* Update the field boost value */
if (field_boost > 0.0) {
if (queue->field_boost > 0.0) {
queue->field_boost *= field_boost;
} else {
queue->field_boost = field_boost;
}
}
}
queue->count++;
return SUCCESS;
}
开发者ID:erning,项目名称:php-pecl-solr,代码行数:57,代码来源:solr_functions_document.c
示例19: pemalloc
/* {{{ php_mb_regex_globals_alloc */
zend_mb_regex_globals *php_mb_regex_globals_alloc(void)
{
zend_mb_regex_globals *pglobals = pemalloc(
sizeof(zend_mb_regex_globals), 1);
if (SUCCESS != _php_mb_regex_globals_ctor(pglobals)) {
pefree(pglobals, 1);
return NULL;
}
return pglobals;
}
开发者ID:AllenJB,项目名称:php-src,代码行数:11,代码来源:php_mbregex.c
示例20: php_driver_new_peref
php_driver_ref*
php_driver_new_peref(void *data, php_driver_free_function destructor, int persistent)
{
php_driver_ref *ref = (php_driver_ref*) pemalloc(sizeof(php_driver_ref), persistent);
ref->data = data;
ref->destruct = destructor;
ref->count = 1;
return ref;
}
开发者ID:datastax,项目名称:php-driver,代码行数:11,代码来源:ref.c
注:本文中的pemalloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论