phpdbg_btree.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Felipe Pena <felipe@php.net> |
  16. | Authors: Joe Watkins <joe.watkins@live.co.uk> |
  17. | Authors: Bob Weinand <bwoebi@php.net> |
  18. +----------------------------------------------------------------------+
  19. */
  20. #ifndef PHPDBG_BTREE_H
  21. #define PHPDBG_BTREE_H
  22. #include "zend.h"
  23. typedef struct {
  24. zend_ulong idx;
  25. void *ptr;
  26. } phpdbg_btree_result;
  27. typedef union _phpdbg_btree_branch phpdbg_btree_branch;
  28. union _phpdbg_btree_branch {
  29. phpdbg_btree_branch *branches[2];
  30. phpdbg_btree_result result;
  31. };
  32. typedef struct {
  33. zend_ulong count;
  34. zend_ulong depth;
  35. phpdbg_btree_branch *branch;
  36. } phpdbg_btree;
  37. typedef struct {
  38. phpdbg_btree *tree;
  39. zend_ulong cur;
  40. zend_ulong end;
  41. } phpdbg_btree_position;
  42. void phpdbg_btree_init(phpdbg_btree *tree, zend_ulong depth);
  43. phpdbg_btree_result *phpdbg_btree_find(phpdbg_btree *tree, zend_ulong idx);
  44. phpdbg_btree_result *phpdbg_btree_find_closest(phpdbg_btree *tree, zend_ulong idx);
  45. phpdbg_btree_position phpdbg_btree_find_between(phpdbg_btree *tree, zend_ulong lower_idx, zend_ulong higher_idx);
  46. phpdbg_btree_result *phpdbg_btree_next(phpdbg_btree_position *pos);
  47. int phpdbg_btree_delete(phpdbg_btree *tree, zend_ulong idx);
  48. #define PHPDBG_BTREE_INSERT 1
  49. #define PHPDBG_BTREE_UPDATE 2
  50. #define PHPDBG_BTREE_OVERWRITE (PHPDBG_BTREE_INSERT | PHPDBG_BTREE_UPDATE)
  51. int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr, int flags);
  52. #define phpdbg_btree_insert(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_INSERT)
  53. #define phpdbg_btree_update(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_UPDATE)
  54. #define phpdbg_btree_overwrite(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_OWERWRITE)
  55. #endif