mirror of
https://github.com/topjohnwu/selinux.git
synced 2025-02-12 23:08:51 +00:00
libsepol: Add new ebitmap function named ebitmap_match_any()
This function returns true if there is a common bit that is set in both bitmaps. Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
This commit is contained in:
parent
aab9d90b35
commit
49f7ebb04c
@ -86,6 +86,7 @@ extern unsigned int ebitmap_cardinality(ebitmap_t *e1);
|
||||
extern int ebitmap_hamming_distance(ebitmap_t * e1, ebitmap_t * e2);
|
||||
extern int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src);
|
||||
extern int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2);
|
||||
extern int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2);
|
||||
extern int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit);
|
||||
extern int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value);
|
||||
extern void ebitmap_destroy(ebitmap_t * e);
|
||||
|
@ -224,6 +224,28 @@ int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
|
||||
{
|
||||
ebitmap_node_t *n1 = e1->node;
|
||||
ebitmap_node_t *n2 = e2->node;
|
||||
|
||||
while (n1 && n2) {
|
||||
if (n1->startbit < n2->startbit) {
|
||||
n1 = n1->next;
|
||||
} else if (n2->startbit < n1->startbit) {
|
||||
n2 = n2->next;
|
||||
} else {
|
||||
if (n1->map & n2->map) {
|
||||
return 1;
|
||||
}
|
||||
n1 = n1->next;
|
||||
n2 = n2->next;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit)
|
||||
{
|
||||
ebitmap_node_t *n;
|
||||
|
Loading…
x
Reference in New Issue
Block a user