diff options
Diffstat (limited to 'src/os/win32')
| -rw-r--r-- | src/os/win32/ngx_alloc.c | 36 | ||||
| -rw-r--r-- | src/os/win32/ngx_alloc.h | 18 | ||||
| -rw-r--r-- | src/os/win32/ngx_win32_init.c | 4 |
3 files changed, 58 insertions, 0 deletions
diff --git a/src/os/win32/ngx_alloc.c b/src/os/win32/ngx_alloc.c new file mode 100644 index 000000000..591e61bcb --- /dev/null +++ b/src/os/win32/ngx_alloc.c @@ -0,0 +1,36 @@ + +#include <ngx_config.h> +#include <ngx_core.h> + + +int ngx_pagesize; + + +void *ngx_alloc(size_t size, ngx_log_t *log) +{ + void *p; + + if (!(p = malloc(size))) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, + "malloc() " SIZE_T_FMT " bytes failed", size); + } + + ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, + "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size); + + return p; +} + + +void *ngx_calloc(size_t size, ngx_log_t *log) +{ + void *p; + + p = ngx_alloc(size, log); + + if (p) { + ngx_memzero(p, size); + } + + return p; +} diff --git a/src/os/win32/ngx_alloc.h b/src/os/win32/ngx_alloc.h new file mode 100644 index 000000000..d6ea00a2b --- /dev/null +++ b/src/os/win32/ngx_alloc.h @@ -0,0 +1,18 @@ +#ifndef _NGX_ALLOC_H_INCLUDED_ +#define _NGX_ALLOC_H_INCLUDED_ + + +#include <ngx_config.h> +#include <ngx_core.h> + + +void *ngx_alloc(size_t size, ngx_log_t *log); +void *ngx_calloc(size_t size, ngx_log_t *log); + +#define ngx_free free +#define ngx_memalign(alignment, size, log) ngx_alloc(size, log) + +extern int ngx_pagesize; + + +#endif /* _NGX_ALLOC_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c index c4ffc1121..7a25b2845 100644 --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -40,6 +40,7 @@ int ngx_os_init(ngx_log_t *log) DWORD bytes; SOCKET s; WSADATA wsd; + SYSTEM_INFO si; OSVERSIONINFOEX osvi; ngx_osviex_stub_t *osviex_stub; @@ -121,6 +122,9 @@ int ngx_os_init(ngx_log_t *log) } } + GetSystemInfo(&si); + ngx_pagesize = si.dwPageSize; + /* init Winsock */ |
