<p><a href="https://github.com/bogdan-iancu" class="user-mention">@bogdan-iancu</a>, I did a small review.</p>

<p>I have a doubts about this one block of code in <code>lb_route()</code> function:</p>

<div class="highlight highlight-c++"><pre>        <span class="pl-c">/* save state - res */</span>
        <span class="pl-c">/* iterate AVPs once and delete old resources */</span>
        <span class="pl-en">destroy_avps</span>(<span class="pl-c1">0</span>, res_avp_name, <span class="pl-c1">1</span> <span class="pl-c">/*all*/</span>);
        <span class="pl-c">/* add new resources */</span>
        <span class="pl-k">for</span>( i=<span class="pl-c1">0</span> ; i&lt;res_cur_n ; i++ ) {
                res_val.<span class="pl-vo">s</span> = res_cur[i]-&gt;name;
                <span class="pl-k">if</span>( <span class="pl-s3">add_avp</span>(AVP_VAL_STR, res_avp_name, res_val) != <span class="pl-c1">0</span> )
                        <span class="pl-s3">LM_ERR</span>(<span class="pl-s1"><span class="pl-pds">"</span>failed to add RES AVP<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>);
        }</pre></div>

<p>Previously we searched through AVPs and delete old/add new.<br>
This way we could be sure that no unnecessary memory allocations are made.<br>
Our usual scenario is a continuous call of <code>lb_next()</code> with cached/unchanged resources list.</p>

<p>So we usually expect no memory allocations when handling resources list AVPs during subsequent <code>lb_next()</code> calls.</p>

<p>This is not true in your version of code.</p>

<p>What do you think?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/345#issuecomment-71644836">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciaLVoGcdHHiIHpDw8MaMYNEDw5Mkks5nl4VXgaJpZM4CpiN1.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/OpenSIPS/opensips/pull/345#issuecomment-71644836"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>