zend_stack.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_STACK_H
  20. #define ZEND_STACK_H
  21. typedef struct _zend_stack {
  22. int size, top, max;
  23. void *elements;
  24. } zend_stack;
  25. #define STACK_BLOCK_SIZE 16
  26. BEGIN_EXTERN_C()
  27. ZEND_API void zend_stack_init(zend_stack *stack, int size);
  28. ZEND_API int zend_stack_push(zend_stack *stack, const void *element);
  29. ZEND_API void *zend_stack_top(const zend_stack *stack);
  30. ZEND_API void zend_stack_del_top(zend_stack *stack);
  31. ZEND_API int zend_stack_int_top(const zend_stack *stack);
  32. ZEND_API bool zend_stack_is_empty(const zend_stack *stack);
  33. ZEND_API void zend_stack_destroy(zend_stack *stack);
  34. ZEND_API void *zend_stack_base(const zend_stack *stack);
  35. ZEND_API int zend_stack_count(const zend_stack *stack);
  36. ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element));
  37. ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg);
  38. ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), bool free_elements);
  39. END_EXTERN_C()
  40. #define ZEND_STACK_APPLY_TOPDOWN 1
  41. #define ZEND_STACK_APPLY_BOTTOMUP 2
  42. #endif /* ZEND_STACK_H */