[Asterisk-code-review] astobj2: Create case-insensitive variants of container funct... (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Jan 2 11:55:03 CST 2018


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/7774 )

Change subject: astobj2: Create case-insensitive variants of container function macros.
......................................................................


Patch Set 1: Code-Review-1

(2 comments)

Some points to consider.

https://gerrit.asterisk.org/#/c/7774/1/include/asterisk/astobj2.h
File include/asterisk/astobj2.h:

https://gerrit.asterisk.org/#/c/7774/1/include/asterisk/astobj2.h@2084
PS1, Line 2084: 	const char *right_key = arg; \
The macros assume that the key is a char string.  It doesn't have to be.  The key could be several strings or something else.  I suppose if the key is something else then we'll have to not use the convenience macros since it would be an exception case.


https://gerrit.asterisk.org/#/c/7774/1/include/asterisk/astobj2.h@2093
PS1, Line 2093: 		cmp = partial_key_cmp(object_left->field, right_key, strlen(right_key)); \
A partial key search could pass in a different type to avoid doing a strlen() of the key for every call.  See ao2_reg_sort_cb() for example.

struct partial_key {
  const char *key;
  int length;
}

Thus:
case OBJ_SEARCH_PARTIAL_KEY:
   {
      const struct partial_key *partial = arg;
      cmp = partial_key_cmp(object_left->field, partial);
   }

Where partial_key_cmp() could be defined as:
#define partial_key_cmp(left, partial) \
   strncmp(left, partial->key, partial->length)



-- 
To view, visit https://gerrit.asterisk.org/7774
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: I11af8c6a0c43380a42732553f519c667abb842cf
Gerrit-Change-Number: 7774
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Tue, 02 Jan 2018 17:55:03 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180102/f504a8b9/attachment.html>


More information about the asterisk-code-review mailing list