<p>Richard Mudgett <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/8521">View Change</a></p><p>Patch set 2:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p style="white-space: pre-wrap; word-wrap: break-word;">__ast_calloc() is NOT the same as calloc().</p><p>(5 comments)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/8521/2/include/asterisk/astmm.h">File include/asterisk/astmm.h:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/2/include/asterisk/astmm.h@55">Patch Set #2, Line 55:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;<br>void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;<br>void *__ast_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc;<br>void __ast_free(void *ptr, const char *file, int lineno, const char *func);<br>void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);<br>char *__ast_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc;<br>char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc;<br>int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)<br>     __attribute__((format(printf, 5, 6)));<br>int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)<br>      __attribute__((format(printf, 2, 0)));<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">You need both __ast_repl_calloc() and __ast_calloc() prototype versions declared here.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/2/include/asterisk/astmm.h@134">Patch Set #2, Line 134:</a> <code style="font-family:monospace,monospace">    __ast_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">__ast_calloc() is NOT the same as calloc().  __ast_calloc() also checks and logs allocation failures using Asterisk's logging system.</p><p style="white-space: pre-wrap; word-wrap: break-word;">When MALLOC_DEBUG is enabled the replacement calloc() (__ast_repl_calloc()) logs to MALLOC_DEBUG's logger for debugging purposes not Asterisk's logging system.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/2/main/astmm.c">File main/astmm.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/2/main/astmm.c@1557">Patch Set #2, Line 1557:</a> <code style="font-family:monospace,monospace">void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">You have reverted part of the improvement I did with the always MALLOC_DEBUG API change.  __ast_calloc() called __ast_repl_calloc() where __ast_repl_calloc() is either the standard calloc or the MALLOC_DEBUG calloc replacement.</p><ul><li>The primary reason for __ast_calloc() being different from __ast_repl_calloc() is when MALLOC_DEBUG is enabled it would still check and give the MALLOC_FAILURE_MSG log when the code called __ast_calloc().</li></ul><ul><li>DEBUG_CHAOS is again incompatible with MALLOC_DEBUG.  (Which I just found out that menuselect should have been updated to remove the conflicts with MALLOC_DEBUG restraint. :) )</li></ul></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/2/third-party/pjproject/patches/asterisk_malloc_debug.h">File third-party/pjproject/patches/asterisk_malloc_debug.h:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/2/third-party/pjproject/patches/asterisk_malloc_debug.h@28">Patch Set #2, Line 28:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)<br>  __attribute__((format(printf, 5, 6)));<br>void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);<br>void __ast_free(void *ptr, const char *file, int lineno, const char *func);<br>void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);<br>void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);<br>char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);<br>char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);<br>int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)<br>      __attribute__((format(printf, 2, 0)));<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Restore the __ast_repl_xxx prototypes.  Should add the attribute_malloc though.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/8521/2/utils/Makefile">File utils/Makefile:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/8521/2/utils/Makefile@103">Patch Set #2, Line 103:</a> <code style="font-family:monospace,monospace">astman.o: _ASTCFLAGS+=-DNO_MALLOC_DEBUG</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is where NO_MALLOC_DEBUG is defined.  NO_MALLOC_DEBUG doesn't seem needed anymore in the code.  The only place it would have an effect now is in astmm.c and it is never set there.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/8521">change 8521</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8521"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: If9df4377f74bdbb627461b27a473123e05525887 </div>
<div style="display:none"> Gerrit-Change-Number: 8521 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 14 Mar 2018 19:35:09 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>