From: Jaroslav Kysela Date: Tue, 5 Dec 2017 19:46:15 +0000 (+0100) Subject: idnode: add idnode_find0() function X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b473b1400c6bfdf905dd59a00bed873155abcbe9;p=thirdparty%2Ftvheadend.git idnode: add idnode_find0() function --- diff --git a/src/idnode.c b/src/idnode.c index 2dd4b4212..638000971 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -608,22 +608,17 @@ idnode_domain(const idclass_t *idc) } } -void * -idnode_find ( const char *uuid, const idclass_t *idc, const idnodes_rb_t *domain ) +static idnode_t * +idnode_find_ ( idnode_t *skel, const idclass_t *idc, const idnodes_rb_t *domain ) { - idnode_t skel, *r; + idnode_t *r; - tvhtrace(LS_IDNODE, "find node %s class %s", uuid, idc ? idc->ic_class : NULL); - if(uuid == NULL || strlen(uuid) != UUID_HEX_SIZE - 1) - return NULL; - if(hex2bin(skel.in_uuid.bin, sizeof(skel.in_uuid.bin), uuid)) - return NULL; if (domain == NULL) domain = idnode_domain(idc); if (domain == NULL) - r = RB_FIND(&idnodes, &skel, in_link, in_cmp); + r = RB_FIND(&idnodes, skel, in_link, in_cmp); else - r = RB_FIND(domain, &skel, in_domain_link, in_cmp); + r = RB_FIND(domain, skel, in_domain_link, in_cmp); if(r != NULL && idc != NULL) { const idclass_t *c = r->in_class; for(;c != NULL; c = c->ic_super) { @@ -635,6 +630,29 @@ idnode_find ( const char *uuid, const idclass_t *idc, const idnodes_rb_t *domain return r; } +void * +idnode_find0 ( tvh_uuid_t *uuid, const idclass_t *idc, const idnodes_rb_t *domain ) +{ + char buf[UUID_HEX_SIZE]; + idnode_t skel; + skel.in_uuid = *uuid; + tvhtrace(LS_IDNODE, "find node %s class %s", + uuid_get_hex(uuid, buf), idc ? idc->ic_class : NULL); + return idnode_find_(&skel, idc, domain); +} + +void * +idnode_find ( const char *uuid, const idclass_t *idc, const idnodes_rb_t *domain ) +{ + idnode_t skel; + tvhtrace(LS_IDNODE, "find node %s class %s", uuid, idc ? idc->ic_class : NULL); + if(uuid == NULL || strlen(uuid) != UUID_HEX_SIZE - 1) + return NULL; + if(hex2bin(skel.in_uuid.bin, sizeof(skel.in_uuid.bin), uuid)) + return NULL; + return idnode_find_(&skel, idc, domain); +} + idnode_set_t * idnode_find_all ( const idclass_t *idc, const idnodes_rb_t *domain ) { diff --git a/src/idnode.h b/src/idnode.h index f6e5ccd12..8ffafe962 100644 --- a/src/idnode.h +++ b/src/idnode.h @@ -217,6 +217,7 @@ void idnode_movedown (idnode_t *in); void idnode_changed (idnode_t *in); void *idnode_find (const char *uuid, const idclass_t *idc, const idnodes_rb_t *nodes); +void *idnode_find0 (tvh_uuid_t *uuid, const idclass_t *idc, const idnodes_rb_t *nodes); idnode_set_t *idnode_find_all(const idclass_t *idc, const idnodes_rb_t *nodes);