<p><a href="https://gerrit.asterisk.org/10981">View Change</a></p><p>1 comment:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/10981/1/main/strings.c">File main/strings.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10981/1/main/strings.c@253">Patch Set #1, Line 253:</a> <code style="font-family:monospace,monospace"> return -2;</code></p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Returning -2 is truly weird and unexpected for a compare function. <br>As a result you couldn't use it with qsort() and expect a sorted<br>array. This should be 0 as both left and right strings are the<br>same (i.e., NULL).</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">It is odd I agree, but I wanted it to fail if a NULL pointer was set for one or both. At least for the use case I had, but the more expected/generic use case is probably to return 0. I toyed with that and adding a separate function. I guess I could do something like that.</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Another question: Should NULL pointers be considered greater than<br>non-NULL pointers. You currently sort NULL pointers before<br>non-NULL pointers. It seems it would be more useful to sort NULL<br>pointers to the end of an array.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I used the reasoning that NULL is essentially less than anything, but sorting to the end makes sense, so I'll change.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/10981">change 10981</a>. To unsubscribe, or for help writing mail filters, 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/10981"/><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: I26f0a16d61537505eb41b4b05ef2e6d67fc2541b </div>
<div style="display:none"> Gerrit-Change-Number: 10981 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Fri, 08 Feb 2019 22:21:52 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: No </div>