src/core/ngx_slab.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_SLAB_H_INCLUDED_
  6. #define _NGX_SLAB_H_INCLUDED_


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


  9. typedef struct ngx_slab_page_s  ngx_slab_page_t;

  10. struct ngx_slab_page_s {
  11.     uintptr_t         slab;
  12.     ngx_slab_page_t  *next;
  13.     uintptr_t         prev;
  14. };


  15. typedef struct {
  16.     ngx_shmtx_sh_t    lock;

  17.     size_t            min_size;
  18.     size_t            min_shift;

  19.     ngx_slab_page_t  *pages;
  20.     ngx_slab_page_t  *last;
  21.     ngx_slab_page_t   free;

  22.     u_char           *start;
  23.     u_char           *end;

  24.     ngx_shmtx_t       mutex;

  25.     u_char           *log_ctx;
  26.     u_char            zero;

  27.     unsigned          log_nomem:1;

  28.     void             *data;
  29.     void             *addr;
  30. } ngx_slab_pool_t;


  31. void ngx_slab_init(ngx_slab_pool_t *pool);
  32. void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size);
  33. void *ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size);
  34. void *ngx_slab_calloc(ngx_slab_pool_t *pool, size_t size);
  35. void *ngx_slab_calloc_locked(ngx_slab_pool_t *pool, size_t size);
  36. void ngx_slab_free(ngx_slab_pool_t *pool, void *p);
  37. void ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p);


  38. #endif /* _NGX_SLAB_H_INCLUDED_ */