src/os/win32/ngx_alloc.c - nginx source code

Global variables defined

Functions defined

Source code


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


  5. #include <ngx_config.h>
  6. #include <ngx_core.h>


  7. ngx_uint_t  ngx_pagesize;
  8. ngx_uint_t  ngx_pagesize_shift;
  9. ngx_uint_t  ngx_cacheline_size;


  10. void *ngx_alloc(size_t size, ngx_log_t *log)
  11. {
  12.     void  *p;

  13.     p = malloc(size);
  14.     if (p == NULL) {
  15.         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
  16.                       "malloc(%uz) failed", size);
  17.     }

  18.     ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %p:%uz", p, size);

  19.     return p;
  20. }


  21. void *ngx_calloc(size_t size, ngx_log_t *log)
  22. {
  23.     void  *p;

  24.     p = ngx_alloc(size, log);

  25.     if (p) {
  26.         ngx_memzero(p, size);
  27.     }

  28.     return p;
  29. }