src/core/ngx_radix_tree.h - nginx-1.7.10

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_RADIX_TREE_H_INCLUDED_
  6. #define _NGX_RADIX_TREE_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>


  9. #define NGX_RADIX_NO_VALUE   (uintptr_t) -1

  10. typedef struct ngx_radix_node_s  ngx_radix_node_t;

  11. struct ngx_radix_node_s {
  12.     ngx_radix_node_t  *right;
  13.     ngx_radix_node_t  *left;
  14.     ngx_radix_node_t  *parent;
  15.     uintptr_t          value;
  16. };


  17. typedef struct {
  18.     ngx_radix_node_t  *root;
  19.     ngx_pool_t        *pool;
  20.     ngx_radix_node_t  *free;
  21.     char              *start;
  22.     size_t             size;
  23. } ngx_radix_tree_t;


  24. ngx_radix_tree_t *ngx_radix_tree_create(ngx_pool_t *pool,
  25.     ngx_int_t preallocate);

  26. ngx_int_t ngx_radix32tree_insert(ngx_radix_tree_t *tree,
  27.     uint32_t key, uint32_t mask, uintptr_t value);
  28. ngx_int_t ngx_radix32tree_delete(ngx_radix_tree_t *tree,
  29.     uint32_t key, uint32_t mask);
  30. uintptr_t ngx_radix32tree_find(ngx_radix_tree_t *tree, uint32_t key);

  31. #if (NGX_HAVE_INET6)
  32. ngx_int_t ngx_radix128tree_insert(ngx_radix_tree_t *tree,
  33.     u_char *key, u_char *mask, uintptr_t value);
  34. ngx_int_t ngx_radix128tree_delete(ngx_radix_tree_t *tree,
  35.     u_char *key, u_char *mask);
  36. uintptr_t ngx_radix128tree_find(ngx_radix_tree_t *tree, u_char *key);
  37. #endif


  38. #endif /* _NGX_RADIX_TREE_H_INCLUDED_ */