From 36aec3d75898a4f695f2a5759706312bdb82deee Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 14 May 2025 19:36:33 -0700 Subject: [PATCH] Modules: introduced NGX_CHB_CTX_INIT(). --- nginx/ngx_js.h | 3 +++ src/njs_chb.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nginx/ngx_js.h b/nginx/ngx_js.h index bb7c1d26..ceb82f74 100644 --- a/nginx/ngx_js.h +++ b/nginx/ngx_js.h @@ -317,6 +317,9 @@ ngx_int_t ngx_js_exception(njs_vm_t *vm, ngx_str_t *s); ngx_engine_t *ngx_njs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf, void *external); +#define NGX_CHB_CTX_INIT(chain, pool) \ + njs_chb_init(chain, pool, (njs_chb_alloc_t) ngx_palloc, NULL) + #if (NJS_HAVE_QUICKJS) typedef struct ngx_qjs_event_s ngx_qjs_event_t; diff --git a/src/njs_chb.c b/src/njs_chb.c index 3ee28009..ac88c0bd 100644 --- a/src/njs_chb.c +++ b/src/njs_chb.c @@ -251,7 +251,11 @@ njs_chb_destroy(njs_chb_t *chain) while (n != NULL) { next = n->next; - chain->free(chain->pool, n); + + if (chain->free != NULL) { + chain->free(chain->pool, n); + } + n = next; } } -- 2.47.3