Skip to content

Commit

Permalink
libsepol/cil: Add function to get number of items in a stack
Browse files Browse the repository at this point in the history
Add the function, cil_stack_number_of_items(), to return the number
of items in the stack.

Signed-off-by: James Carter <[email protected]>
  • Loading branch information
jwcart2 authored and bachradsusi committed Sep 8, 2021
1 parent c304156 commit d0b5ba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libsepol/cil/src/cil_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ int cil_stack_is_empty(struct cil_stack *stack)
return (stack->pos == -1);
}

int cil_stack_number_of_items(struct cil_stack *stack)
{
return stack->pos + 1;
}

void cil_stack_push(struct cil_stack *stack, enum cil_flavor flavor, void *data)
{
stack->pos++;
Expand Down
1 change: 1 addition & 0 deletions libsepol/cil/src/cil_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void cil_stack_destroy(struct cil_stack **stack);

void cil_stack_empty(struct cil_stack *stack);
int cil_stack_is_empty(struct cil_stack *stack);
int cil_stack_number_of_items(struct cil_stack *stack);

void cil_stack_push(struct cil_stack *stack, enum cil_flavor flavor, void *data);
struct cil_stack_item *cil_stack_pop(struct cil_stack *stack);
Expand Down

0 comments on commit d0b5ba0

Please sign in to comment.