<p></p>
<p>This works when listening on a single socket, right?</p>
<p>While that is ok for some use cases, if you want to have the advertised address of a listen socket, then this can be coded in a different way, by saving <code>socket->useinfo.sock_str</code> instead of <code>socket->sock_str</code>.</p>
<p>If you still want to have a parameter like in your patch, it is fine for me, even it has rather limited usage, but in this case I think it should use a static variable in pack_ci() function, like all the other variables in the function that are used outside, to avoid the pkg_malloc() and the pkg_free(), so declare:</p>
<pre><code>static struct socket_info si = {0};
</code></pre>
<p>Then have something like:</p>
<pre><code>         if (sock_addr.len>0) {
                        memset(&si, 0, sizeof(struct socket_info));
                        si.sock_str = sock_addr;
                        ci.sock = &si;
...
</code></pre>
<p>Then IF blocks to do <code>pkg_free(si);</code> and <code>pkg_free(ci->sock);</code> should dissapear, having the changes only inside the pack_ci() function.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/2498#issuecomment-703753670">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZOUQSMIM6GZ6RMB7BLSJH2FZANCNFSM4SE4ZIWQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZJS733G4WBLC4PB3XTSJH2FZA5CNFSM4SE4ZIW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFHZG3RQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/2498#issuecomment-703753670",
"url": "https://github.com/kamailio/kamailio/pull/2498#issuecomment-703753670",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>