当前位置: 首页>>代码示例>>C++>>正文


C++ smart_str_free函数代码示例

本文整理汇总了C++中smart_str_free函数的典型用法代码示例。如果您正苦于以下问题:C++ smart_str_free函数的具体用法?C++ smart_str_free怎么用?C++ smart_str_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了smart_str_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: php_bencode_decode_int

static void php_bencode_decode_int(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
	int len = 0;
	double d;
	smart_str buf = {0};
	(*pos)++;
	while (*pos < *str_len && str[*pos] != PHP_BENCODE_END_STRUCTURE) {
		smart_str_appendc(&buf, str[*pos]);
		(*pos)++;
		len++;
	}
	smart_str_0(&buf);
	
	if (str[*pos] != PHP_BENCODE_END_STRUCTURE) {
		smart_str_free(&buf);
		zend_error(E_WARNING, "Invaild bencoded-integer, expected 'e'.");
		RETURN_NULL();
	}
	
	(*pos)++;
	
	ZVAL_STRINGL(return_value, ZSTR_VAL(buf.s), len);
	d = zend_strtod(ZSTR_VAL(buf.s), NULL);
	if (d <= ZEND_LONG_MAX && d >= ZEND_LONG_MIN) {
		convert_to_long(return_value);
	}
	smart_str_free(&buf);
	
}
开发者ID:acgrid,项目名称:php-ext-bencode,代码行数:29,代码来源:cg_bcode.c

示例2: SAPI_POST_HANDLER_FUNC

SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
{
	zval *arr = (zval *) arg;
	php_stream *s = SG(request_info).request_body;
	post_var_data_t post_data;

	if (s && SUCCESS == php_stream_rewind(s)) {
		memset(&post_data, 0, sizeof(post_data));

		while (!php_stream_eof(s)) {
			char buf[BUFSIZ] = {0};
			size_t len = php_stream_read(s, buf, BUFSIZ);

			if (len && len != (size_t) -1) {
				smart_str_appendl(&post_data.str, buf, len);

				if (SUCCESS != add_post_vars(arr, &post_data, 0)) {
					smart_str_free(&post_data.str);
					return;
				}
			}

			if (len != BUFSIZ){
				break;
			}
		}

		if (post_data.str.s) {
			add_post_vars(arr, &post_data, 1);
			smart_str_free(&post_data.str);
		}
	}
}
开发者ID:Crell,项目名称:php-src,代码行数:33,代码来源:php_variables.c

示例3: cpMD5

zval * cpMD5(zval *arr) {//pass in array , out md5 zval
    smart_str ser_data = {0};
    cp_serialize(&ser_data, arr);

    zval fun_name, **args[1], *retval, *str;
    CP_ZVAL_STRING(&fun_name, "md5", 0);

    CP_MAKE_STD_ZVAL(str);
#if PHP_MAJOR_VERSION < 7
    CP_ZVAL_STRINGL(str, ser_data.c, ser_data.len, 1);
#else
    zend_string *str_data = ser_data.s;
    CP_ZVAL_STRINGL(str, str_data->val, str_data->len, 1);
#endif
    args[0] = &str;

    if (cp_call_user_function_ex(CG(function_table), NULL, &fun_name, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS)
    {
        cp_zval_ptr_dtor(&str);
        smart_str_free(&ser_data);
        return NULL;
    }
    cp_zval_ptr_dtor(&str);
    smart_str_free(&ser_data);
    return retval;
}
开发者ID:Janson-Leung,项目名称:php-cp,代码行数:26,代码来源:cpFunction.c

示例4: to_indexed

/** {{{ to_indexed
*/
static zval * to_indexed(zval * keys, char * query, int len) {
	zval * sql = NULL;
	char   ch  = 0;
	int    i   = 0;
	smart_str skey       = {NULL, 0, 0};
	smart_str ssql       = {NULL, 0, 0};

	for(i=0; i<len; i++) {
		ch = *(query + i);
		if (ch == ':') {
			for (i++; i < len; i++) {
				ch = *(query + i);
				/* [a-zA-Z0-9_]+ */
				if ((ch > 96 && ch < 123)
						|| (ch > 64 && ch < 91)
						|| (ch > 47 && ch < 58)
						|| ch == 95
				   ) {
					smart_str_appendc(&skey, ch);
				} else {
					break;
				}
			}
			smart_str_appendc(&ssql, '?');
			smart_str_appendc(&ssql, ch);

			smart_str_0(&skey);

			if (ssql.len) {
				add_next_index_stringl(keys, skey.c, skey.len, 1);
			}
			smart_str_free(&skey);
		} else {
			smart_str_appendc(&ssql, ch);
		}
	}

	MAKE_STD_ZVAL(sql);
	if (ssql.len) {
		ZVAL_STRINGL(sql, ssql.c, ssql.len, 1);
	}else{
		ZVAL_STRINGL(sql, "", 0, 1);
	}

	smart_str_free(&skey);
	smart_str_free(&ssql);

	return sql;
}
开发者ID:eixom,项目名称:zoeeyphp,代码行数:51,代码来源:recorder.c

示例5: php_discuz_auth_encode

PHPAPI static void php_discuz_auth_encode(smart_str *buf, const char *str, int str_len, const char *key, int keylen, long expiry)
{
	char keya[33], keyb[33], keyc[DISCUZ_AUTH_CKEYLEN+1], cryptkey[65]={0};
        char ret[100], retmd5[33];
        char *pc;
	struct timeval tp = {0};
        smart_str strbuf = {0};
        if (gettimeofday(&tp, NULL)) {
                return;
        }
        snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec);

        php_md5(retmd5, ret, strlen(ret));
        bzero(keyc, sizeof(keyc));
        memcpy(keyc, retmd5 + 32 - DISCUZ_AUTH_CKEYLEN, DISCUZ_AUTH_CKEYLEN);

	php_discuz_auth_initkey(keya, keyb, cryptkey, keyc, key, keylen);
	//$string = sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
	smart_str_appendl(&strbuf, str, str_len);
	smart_str_appendl(&strbuf, keyb, 32);
	php_md5(retmd5, strbuf.c, strbuf.len);
	smart_str_free(&strbuf);

	snprintf(ret, sizeof(ret), "%010d", expiry ? expiry + time(NULL) : 0);
	smart_str_appendl(&strbuf, ret, 10);
	smart_str_appendl(&strbuf, retmd5, 16);
	smart_str_appendl(&strbuf, str, str_len);

	pc = (unsigned char *)safe_emalloc(strbuf.len, sizeof(char), 1);
	php_discuz_authcode(pc, strbuf.c, strbuf.len, cryptkey);

	//return $keyc.str_replace('=', '', base64_encode($result));
	char *result;
	int retlen;
	result = php_base64_encode((unsigned char*)pc, strbuf.len, &retlen);
	efree(pc);	

	int index, to;
	for(index = 0, to = 0; index <= retlen; index++) {
		if(*(result+index) != '=') {
			*(result+to) = *(result+index);
			to++;
		}
	}
	smart_str_appendl(buf, keyc, DISCUZ_AUTH_CKEYLEN);
	smart_str_appendl(buf, result, retlen - (index - to));
	smart_str_free(&strbuf);
}
开发者ID:potterhe,项目名称:php_discuz,代码行数:48,代码来源:discuz.c

示例6: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	php_json_encoder encoder;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", &parameter, &options, &depth) == FAILURE) {
		return;
	}

	php_json_encode_init(&encoder);
	encoder.max_depth = (int)depth;
	encoder.error_code = PHP_JSON_ERROR_NONE;
	php_json_encode_zval(&buf, parameter, (int)options, &encoder);
	JSON_G(error_code) = encoder.error_code;

	if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		RETURN_FALSE;
	}

	smart_str_0(&buf); /* copy? */
	if (buf.s) {
		RETURN_NEW_STR(buf.s);
	}
	RETURN_EMPTY_STRING();
}
开发者ID:unfunco,项目名称:php-src,代码行数:31,代码来源:json.c

示例7: php_memoize_scope

/* {{{ */
static inline zend_string* php_memoize_scope(const zval *This, const zend_function *function) {
	if (!function->common.scope) {
		return NULL;
	}

	if (Z_TYPE_P(This) != IS_OBJECT) {
		return zend_string_copy(function->common.scope->name);
	} else {
		smart_str smart = {0};
		php_serialize_data_t data;

		if (Z_OBJCE_P(This)->serialize == zend_class_serialize_deny) {
			return PHP_MEMOIZE_SCOPE_FAILURE;
		}

		PHP_VAR_SERIALIZE_INIT(data);
		php_var_serialize(&smart, (zval*) This, &data);
		PHP_VAR_SERIALIZE_DESTROY(data);

		if (EG(exception)) {
			smart_str_free(&smart);
			zend_clear_exception();

			return PHP_MEMOIZE_SCOPE_FAILURE;
		}

		return smart.s;
	}

	return NULL;
} /* }}} */
开发者ID:krakjoe,项目名称:memoize,代码行数:32,代码来源:memoize.c

示例8: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	php_json_encoder encoder;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	ZEND_PARSE_PARAMETERS_START(1, 3)
		Z_PARAM_ZVAL_DEREF(parameter)
		Z_PARAM_OPTIONAL
		Z_PARAM_LONG(options)
		Z_PARAM_LONG(depth)
	ZEND_PARSE_PARAMETERS_END();

	php_json_encode_init(&encoder);
	encoder.max_depth = (int)depth;
	encoder.error_code = PHP_JSON_ERROR_NONE;
	php_json_encode_zval(&buf, parameter, (int)options, &encoder);
	JSON_G(error_code) = encoder.error_code;

	if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		RETURN_FALSE;
	}

	smart_str_0(&buf); /* copy? */
	if (buf.s) {
		RETURN_NEW_STR(buf.s);
	}
	RETURN_EMPTY_STRING();
}
开发者ID:ChadSikorra,项目名称:php-src,代码行数:34,代码来源:json.c

示例9: mmc_buffer_free

inline void mmc_buffer_free(mmc_buffer_t *buffer)  /* {{{ */
{
	if (buffer->value.c != NULL) {
		smart_str_free(&(buffer->value));
	}
	memset(buffer, 0, sizeof(*buffer));
}
开发者ID:smoothify-packages,项目名称:php53-memcache,代码行数:7,代码来源:memcache_pool.c

示例10: hs_response_recv

static inline long
hs_response_recv(php_stream *stream, char *recv, size_t size TSRMLS_DC)
{
    long ret;
#ifdef HS_DEBUG
    long i;
    smart_str debug = {0};
#endif

    ret  = php_stream_read(stream, recv, size);
    if (ret <= 0) {
        return -1;
    }
    recv[size] = '\0';

#ifdef HS_DEBUG
    for (i = 0; i < ret; i++) {
        if ((unsigned char)recv[i] == HS_CODE_NULL) {
            smart_str_appendl_ex(&debug, "\\0", strlen("\\0"), 1);
        } else {
            smart_str_appendc(&debug, recv[i]);
        }
    }
    smart_str_0(&debug);
    php_printf("[handlersocket] (recv) %ld : \"%s\"", ret, debug.c);
    smart_str_free(&debug);
#endif

    return ret;
}
开发者ID:amor-tsai,项目名称:php-ext-handlersocketi,代码行数:30,代码来源:response.c

示例11: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", &parameter, &options, &depth) == FAILURE) {
		return;
	}

	JSON_G(error_code) = PHP_JSON_ERROR_NONE;

	JSON_G(encode_max_depth) = (int)depth;

	php_json_encode(&buf, parameter, (int)options);

	if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		ZVAL_FALSE(return_value);
	} else {
		smart_str_0(&buf); /* copy? */
		ZVAL_NEW_STR(return_value, buf.s);
	}
}
开发者ID:CooCoooo,项目名称:php-src,代码行数:27,代码来源:json.c

示例12: php_bencode_decode_str

static void php_bencode_decode_str(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
	size_t len = 0;
	smart_str buf = {0};
	
	while (*pos < *str_len && str[*pos] != ':') {
		smart_str_appendc(&buf, str[*pos]);
		(*pos)++;
	}
	
	if (str[*pos] != ':') {
		zend_error(E_WARNING, "Invaild bencoded-string, expected semicolon, stop at position %u.", *pos);
		RETURN_NULL();
	}
	
	(*pos)++;
	
	smart_str_0(&buf);
	len = atoi(ZSTR_VAL(buf.s));
	smart_str_free(&buf);
	
	if (len > 0 && *pos + len - 1 < *str_len) {
		size_t i;
		for (i = 0; i < len; i++, (*pos)++) {
			smart_str_appendc(&buf, str[*pos]);
		}
		smart_str_0(&buf);
		RETVAL_STR(buf.s);
	} else {
		RETVAL_EMPTY_STRING();
	}
	
}
开发者ID:acgrid,项目名称:php-ext-bencode,代码行数:33,代码来源:cg_bcode.c

示例13: php_url_scanner_ex_deactivate

static int php_url_scanner_ex_deactivate(int type)
{
	url_adapt_state_ex_t *ctx;

	if (type) {
		ctx = &BG(url_adapt_session_ex);
	} else {
		ctx = &BG(url_adapt_output_ex);
	}

	smart_str_free(&ctx->result);
	smart_str_free(&ctx->buf);
	smart_str_free(&ctx->tag);
	smart_str_free(&ctx->arg);
	smart_str_free(&ctx->attr_val);

	return SUCCESS;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:18,代码来源:url_scanner_ex.c

示例14: cp_ser_and_setdis

void cp_ser_and_setdis(zval *arr) {
    smart_str ser_data = {0};
    cp_serialize(&ser_data, arr);
#if PHP_MAJOR_VERSION < 7
    memcpy(CPGL.ping_mem_addr + CP_PING_MD5_LEN + CP_PING_PID_LEN, ser_data.c, ser_data.len);
#else
    zend_string *str = ser_data.s;
    memcpy(CPGL.ping_mem_addr + CP_PING_MD5_LEN + CP_PING_PID_LEN, str->val, str->len);
#endif
    smart_str_free(&ser_data);
}
开发者ID:Janson-Leung,项目名称:php-cp,代码行数:11,代码来源:cpFunction.c

示例15: cpMD5

CPINLINE zval * cpMD5(zval *arr) {//pass in array , out md5 zval
    smart_str ser_data = {0};
    cp_serialize(&ser_data, arr);

    zval fun_name, **args[1], *retval, *str;
    ZVAL_STRING(&fun_name, "md5", 0);

    MAKE_STD_ZVAL(str);
    ZVAL_STRINGL(str, ser_data.c, ser_data.len, 1);
    args[0] = &str;

    if (call_user_function_ex(CG(function_table), NULL, &fun_name, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS)
    {
        zval_ptr_dtor(&str);
        smart_str_free(&ser_data);
        return NULL;
    }
    zval_ptr_dtor(&str);
    smart_str_free(&ser_data);
    return retval;
}
开发者ID:damaainan,项目名称:php-cp,代码行数:21,代码来源:cpFunction.c


注:本文中的smart_str_free函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。