<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/1441/">https://reviewboard.asterisk.org/r/1441/</a>
     </td>
    </tr>
   </table>
   <br />


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

<div>Review request for Asterisk Developers and David Vossel.</div>
<div>By schmidts.</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;">first of all, this is just an idea so be friendly ;)

i have thought about setting a pointer to NULL after it is freed to
avoid segfaults and double free corruptions.

the most important change is to replace the define of ast_free to a
macro which just looks like this:

#define ast_free(x) ({ free((void *)x); x = NULL; })

and also to keep it working proberly change the define of ast_free_ptr
to free instead of ast_free.

the same change happens in astmm.h for malloc debugging calls:

#define ast_free(a) ({ __ast_free((void *) a,__FILE__, __LINE__, __PRETTY_FUNCTION__); a = NULL; })

after doing this changes i have seen a lot of places where a pointer is
cast at the ast_free call to remove the const state of it.
you can see in the diff all this places where this happens but i think
just cast it into void within the macro makes more sense.
because of this small changes the diff is so big, but its the same change on every part of it, except utils.h and astmm.h

only on three places i dont know how to handle this things:
in res_agi.c i had to replace ast_free with free to make it compile, i am sure there would be another way to solve this but i need some help with this.
in config.c i have the same problem like in res_agi.c

format_cap.c is allready cleared with dvossel
</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;">it compiles with and without MALLOC_DEBUG,
it starts
and it do what it should do, the pointer is set to NULL after ast_free</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>trunk/apps/app_dial.c <span style="color: grey">(336161)</span></li>

 <li>trunk/apps/app_voicemail.c <span style="color: grey">(336161)</span></li>

 <li>trunk/channels/chan_sip.c <span style="color: grey">(336161)</span></li>

 <li>trunk/include/asterisk/astmm.h <span style="color: grey">(336161)</span></li>

 <li>trunk/include/asterisk/utils.h <span style="color: grey">(336161)</span></li>

 <li>trunk/main/ccss.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/config.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/datastore.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/event.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/features.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/frame.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/indications.c <span style="color: grey">(336161)</span></li>

 <li>trunk/main/taskprocessor.c <span style="color: grey">(336161)</span></li>

 <li>trunk/res/res_agi.c <span style="color: grey">(336161)</span></li>

</ul>

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




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




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