<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/3689/">https://reviewboard.asterisk.org/r/3689/</a>
     </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On July 2nd, 2014, 3:55 a.m. EDT, <b>Corey Farrell</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/3689/diff/1/?file=62001#file62001line203" style="color: black; font-weight: bold; text-decoration: underline;">/team/group/media_formats-reviewed-trunk/main/format_cap.c</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">int ast_format_cap_add(struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)</pre></td>
   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">int __ast_format_cap_append(struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)</pre></td>

  </tr>
 </tbody>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">203</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">ao2_ref</span><span class="p">(</span><span class="n">framed</span><span class="p">,</span> <span class="o">+</span><span class="mi">1</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I think this ref is leaked.  You don't need a new reference, we already have one from the framed = ao2_alloc.

Original (non-debug) procedure contains this error as well.  Again I'm against duplication of code, I think most of this should be moved to a function shared by the debug and non-debug versions.</pre>
 </blockquote>





</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I got this one wrong.  AST_LIST_INSERT_HEAD(list, framed, entry); used the reference from ao2_alloc, so we do need a second reference for AST_VECTOR_APPEND(&cap->preference_order, framed);</pre>
<br />




<p>- Corey</p>


<br />
<p>On July 2nd, 2014, 7:22 p.m. EDT, Matt Jordan wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By Matt Jordan.</div>


<p style="color: grey;"><i>Updated July 2, 2014, 7:22 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch performs the renaming discussed on the asterisk-dev list [1]. As usual, as I was going through it some other cleanups occurred, and in order to make sure I didn't make memory leaks worse, some parts of Corey's memory leak cleanups made their way in as well.

[1] http://lists.digium.com/pipermail/asterisk-dev/2014-June/068133.html

The great renaming:

 * ast_format_cap_add             => ast_format_cap_append
 * ast_format_cap_add_all_by_type => ast_format_cap_append_all_by_type
 * ast_parse_allow_disallow       => ast_format_cap_update_by_allow_disallow
 * ast_cap_remove_bytype          => ast_format_cap_remove_by_type
 * ast_getformatname_multiple     => ast_format_cap_get_names, and now uses an ast_str ** instead of a char *buf/size_t len
 * ast_format_sdp_generate        => ast_format_generate_sdp_fmtp
 * ast_format_sdp_parse           => ast_format_parse_sdp_fmtp

Functions removed:
 * ast_format_compatibility_get_original_id - no longer used

Note that chan_h323, chan_gtalk, and chan_jingle did not get all of the re-namings (particularly ast_getformatname_multiple => ast_format_cap_get_names), and will not compile with this patch. These modules should be removed, per the discussion on the -dev list.

Functions that support REF_DEBUG:
 * ast_format_cap_alloc
 * ast_format_cap_append
 * ast_format_cache_get

Memory leak cleanups (many of which came from Corey's patches):
 * Channel technology struct capabilities leak their format capabilities on off nominal exit paths (chan_motif, chan_pjsip, chan_unistim, chan_skinny)
 * Format capabilities leak in chan_pjsip_new nominal path
 * Leak of nativeformats format_cap in nominal path of channel.c's ast_channel_alloc
 * Leak of format_cap in channel.c's set_format
 * Leak of format_cap in channel.c's ast_request
 * Usage of ao2_replace in translate.c to avoid overwriting a ref
 * Clean up of frame format cache in RTP instance in res_rtp_asterisk destructor

Unit tests
 * Remove test for ast_getformatname_multiple, add test for ast_format_cap_get_names




</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Negotiation using PJSIP still works.

The most prevalent memory leak that still occurs happens when a statically allocated frame ref bumps a format. This happens a lot when generating translator tables, and in various other places as well.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/tests/test_format_cap.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/tests/test_format_api.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/tests/test_core_format.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/tests/test_config.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_stasis_snoop.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_stasis.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_pjsip_session.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_pjsip/pjsip_configuration.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_clioriginate.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_calendar.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/res_agi.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/parking/parking_applications.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/ari/resource_channels.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/res/ari/resource_bridges.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/pbx/pbx_spool.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/translate.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/sorcery.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/rtp_engine.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/media_index.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/manager.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/format_compatibility.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/format_cap.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/format_cache.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/format.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/file.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/dial.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/core_unreal.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/core_local.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/config_options.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/cli.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/channel.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/ccss.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/bridge_basic.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/main/bridge.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/include/asterisk/format_compatibility.h <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/include/asterisk/format_cap.h <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/include/asterisk/format.h <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/funcs/func_channel.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/pjsip/dialplan_functions.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/dahdi/bridge_native_dahdi.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_unistim.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_skinny.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_sip.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_pjsip.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_phone.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_oss.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_nbs.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_motif.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_misdn.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_jingle.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_iax2.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_h323.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_console.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_bridge_media.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/channels/chan_alsa.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/bridges/bridge_softmix.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/bridges/bridge_simple.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/bridges/bridge_native_rtp.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/bridges/bridge_holding.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/confbridge/conf_chan_record.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/app_voicemail.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/app_originate.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/app_meetme.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/app_dumpchan.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/apps/app_confbridge.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c <span style="color: grey">(417786)</span></li>

 <li>/team/group/media_formats-reviewed-trunk/addons/chan_mobile.c <span style="color: grey">(417786)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/3689/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>