Fix use of OBJ_KEY in Queue application.

To use the new OBJ_KEY flag, the container hash and compare callback
functions must be updated to support OBJ_KEY.  Otherwise, bad things
happen.

(issue ASTERISK-14769)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@342112 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2011-10-24 21:01:58 +00:00
parent 05c6628c55
commit 3e9f1ee3e0

View File

@@ -1678,19 +1678,26 @@ static int compress_char(const char c)
static int member_hash_fn(const void *obj, const int flags)
{
const struct member *mem = obj;
const char *chname = strchr(mem->interface, '/');
const char *interface = (flags & OBJ_KEY) ? obj : mem->interface;
const char *chname = strchr(interface, '/');
int ret = 0, i;
if (!chname)
chname = mem->interface;
for (i = 0; i < 5 && chname[i]; i++)
if (!chname) {
chname = interface;
}
for (i = 0; i < 5 && chname[i]; i++) {
ret += compress_char(chname[i]) << (i * 6);
}
return ret;
}
static int member_cmp_fn(void *obj1, void *obj2, int flags)
{
struct member *mem1 = obj1, *mem2 = obj2;
return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP;
struct member *mem1 = obj1;
struct member *mem2 = obj2;
const char *interface = (flags & OBJ_KEY) ? obj2 : mem2->interface;
return strcasecmp(mem1->interface, interface) ? 0 : CMP_MATCH | CMP_STOP;
}
/*!