提交 58705374 authored 作者: Michael Jerris's avatar Michael Jerris

switch_channel_set_variable_nodup which does not dup the value from the session…

switch_channel_set_variable_nodup which does not dup the value from the session pool.  The value MUST already be allocated from the pool for that session, or very bad things could happen.  Use with caution.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4329 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 ad6cca67
......@@ -210,6 +210,15 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel);
*/
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value);
/*!
\brief Set a variable on a given channel, without duplicating the value from the session pool.
\param channel channel to set variable on
\param varname the name of the variable
\param value the vaule of the variable (MUST BE ALLOCATED FROM THE SESSION POOL ALREADY)
\returns SWITCH_STATUS_SUCCESS if successful
*/
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname, char *value);
/*!
\brief Retrieve a variable from a given channel
\param channel channel to retrieve variable from
......
......@@ -373,6 +373,23 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *ch
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname, char *value)
{
assert(channel != NULL);
if (varname) {
switch_core_hash_delete(channel->variables, varname);
if (!switch_strlen_zero(value)) {
switch_core_hash_insert_dup(channel->variables, varname, value);
} else {
switch_core_hash_delete(channel->variables, varname);
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(int) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags)
{
assert(channel != NULL);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论