add r_stack_peek to the stack api

This commit is contained in:
Lowly Worm 2017-06-06 00:13:51 -04:00
parent 991a1b8dd9
commit e4652c0319
2 changed files with 10 additions and 0 deletions

View File

@ -17,4 +17,5 @@ R_API RStack *r_stack_newf(ut32 n, RStackFree f);
R_API int r_stack_push(RStack *s, void *el);
R_API void *r_stack_pop(RStack *s);
R_API unsigned int r_stack_size(RStack *s);
R_API void *r_stack_peek(RStack *s);
#endif // R_STACK_H

View File

@ -71,3 +71,12 @@ R_API bool r_stack_is_empty(RStack *s) {
R_API unsigned int r_stack_size(RStack *s) {
return (unsigned int)(s->top + 1);
}
R_API void *r_stack_peek(RStack *s) {
void *res;
if (s->top != -1) {
res = s->elems[s->top];
return res;
}
return NULL;
}