nginx/src/core/ngx_alloc.h

55 lines
1.2 KiB
C
Raw Normal View History

#ifndef _NGX_ALLOC_H_INCLUDED_
#define _NGX_ALLOC_H_INCLUDED_
#include <ngx_config.h>
2003-06-03 23:42:58 +08:00
#include <ngx_core.h>
2003-10-23 14:13:16 +08:00
/*
* NGX_MAX_ALLOC_FROM_POOL should be (PAGE_SIZE - 1), i.e. 4095 on x86.
* On FreeBSD 5.x it allows to use zero copy send.
* On Windows NT it decreases number of locked pages in kernel.
2003-04-21 22:55:47 +08:00
*/
#define NGX_MAX_ALLOC_FROM_POOL 4095
#define NGX_DEFAULT_POOL_SIZE (16 * 1024)
2003-01-09 13:36:00 +08:00
#define ngx_test_null(p, alloc, rc) if ((p = alloc) == NULL) { return rc; }
typedef struct ngx_pool_large_s ngx_pool_large_t;
2003-06-03 23:42:58 +08:00
struct ngx_pool_large_s {
ngx_pool_large_t *next;
void *alloc;
};
2003-06-03 23:42:58 +08:00
typedef struct ngx_pool_s ngx_pool_t;
struct ngx_pool_s {
char *last;
char *end;
ngx_pool_t *next;
ngx_pool_large_t *large;
ngx_log_t *log;
};
void *ngx_alloc(size_t size, ngx_log_t *log);
void *ngx_calloc(size_t size, ngx_log_t *log);
ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log);
void ngx_destroy_pool(ngx_pool_t *pool);
void *ngx_palloc(ngx_pool_t *pool, size_t size);
void *ngx_pcalloc(ngx_pool_t *pool, size_t size);
2003-10-23 14:13:16 +08:00
void ngx_pfree(ngx_pool_t *pool, void *p);
2003-05-20 00:39:14 +08:00
#define ngx_free free
#endif /* _NGX_ALLOC_H_INCLUDED_ */