@henningw commented on this pull request.
The code looks all fine, but i noticed that several of the functions are more or less
identical to the existing xavp code. This is of course to be expected, as the value works
differs only in the case handling. I think it is worthwhile to try if it could be
generalized.
What do you think about just using a generic function that gets a function pointer to a
comparison or hash function? E.g. like this (pseudo-code to the relevant parts);
- static sr_xavp_t *xavi_new_value(str *name, sr_xval_t *val, void * hash_func) { id =
hash_func(name->s, name->len); }
- int xavi_add(sr_xavp_t *xavi, sr_xavp_t **list, sr_avp_t* core_list) { *core_list =
xavi; }
- static sr_xavp_t *xavi_get_internal(str *name, sr_xavp_t **list, int idx, sr_xavp_t
**prv, void *hash_func, void* comp_func) { id = hash_func(..); if (.. &&
comp_func(...)) }
Using void* function pointers is of course not perfect, but this is what C gives us. In
e.g. the DB1 API they are used in different functions in a similar way to prevent a lot of
code duplication.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2337#pullrequestreview-421042205