[Freeswitch-dev] Question about switch_channel_get_variable()

Pat Beirne patb at apphostcanada.ca
Fri Oct 2 15:48:14 MSD 2015


I'd like to ask a question about switch_channel_get_variable()

In the include/switch_channel, it's a #define with the 3rd field set to TRUE

<code>
#define switch_channel_get_variable(_c, _v)
switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1)
</code>

When I tunnel into the src/switch_channel.c code, it seems that this
"TRUE" should invoke the _strdup version, and create a return value
taken from the pool

And indeed, my testing shows that every time I call
switch_channel_get_variable(), I get a new distinct pointer..........
but..........the return value is "const char*" so I can't free it

And NONE of the sample code shows the return value being free'd;
sometimes the return value isn't even assigned.....it's just tested and
discarded

for example: newest FS1.6, src/switch_core_state_machine.c, line 264:
<code>
        if (switch_channel_get_variable(session->channel, "recovered")
&& !switch_channel_test_flag(session->channel, CF_RECOVERED)) {
                switch_channel_set_flag(session->channel, CF_RECOVERED);
</code>

Is this a problem in the code or a problem in my understanding?

Pat





Join us at ClueCon 2014 Aug 4-7, 2014
More information about the FreeSWITCH-dev mailing list