[Asterisk-code-review] datastore: Add common container based datastores API. (asterisk[master])
George Joseph
asteriskteam at digium.com
Mon May 9 08:31:05 CDT 2016
George Joseph has posted comments on this change.
Change subject: datastore: Add common container based datastores API.
......................................................................
Patch Set 1: Code-Review-1
(6 comments)
https://gerrit.asterisk.org/#/c/2777/1/include/asterisk/datastore.h
File include/asterisk/datastore.h:
PS1, Line 144: uid
How about "uuid" instead of "uid"? That way it doesn't look like "user id".
PS1, Line 151: uid
see above
https://gerrit.asterisk.org/#/c/2777/1/main/datastore.c
File main/datastore.c:
PS1, Line 92: /*! \brief Hashing function for datastores */
: static int datastore_hash(const void *obj, const int flags)
: {
: const struct ast_datastore *object;
: const char *key;
:
: switch (flags & OBJ_SEARCH_MASK) {
: case OBJ_SEARCH_KEY:
: key = obj;
: break;
: case OBJ_SEARCH_OBJECT:
: object = obj;
: key = object->uid;
: break;
: default:
: ast_assert(0);
: return 0;
: }
: return ast_str_hash(key);
: }
You can use AO2_STRING_FIELD_HASH_FN() now.
PS1, Line 113: /*! \brief Comparator function for datastores */
: static int datastore_cmp(void *obj, void *arg, int flags)
: {
: const struct ast_datastore *object_left = obj;
: const struct ast_datastore *object_right = arg;
: const char *right_key = arg;
: int cmp;
:
: switch (flags & OBJ_SEARCH_MASK) {
: case OBJ_SEARCH_OBJECT:
: right_key = object_right->uid;
: /* Fall through */
: case OBJ_SEARCH_KEY:
: cmp = strcmp(object_left->uid, right_key);
: break;
: case OBJ_SEARCH_PARTIAL_KEY:
: /* Not supported by container. */
: ast_assert(0);
: return 0;
: default:
: cmp = 0;
: break;
: }
: if (cmp) {
: return 0;
: }
: return CMP_MATCH;
: }
Unless you really need to prevent a search by partial key, you can use AO2_STRING_FIELD_CMP_FN() now.
PS1, Line 167: OBJ_KEY
OBJ_SEARCH_KEY
Line 186: RAII_VAR(struct ast_datastore *, datastore, NULL, ao2_cleanup);
<channeling_richard>Unnecessary use of RAII_VAR</channeling_richard>
--
To view, visit https://gerrit.asterisk.org/2777
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I72eb15941dcdbc2a37bb00a33ce00f8755bd336a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-HasComments: Yes
More information about the asterisk-code-review
mailing list