changeset 2557:c042da9331ca

Modules: introduced NGX_CHB_CTX_INIT().
author Dmitry Volyntsev <xeioex@nginx.com>
date Wed, 14 May 2025 19:36:33 -0700
parents 8cc5011c3f73
children 645e86e27836
files nginx/ngx_js.h src/njs_chb.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/nginx/ngx_js.h	Wed May 14 18:00:23 2025 -0700
+++ b/nginx/ngx_js.h	Wed May 14 19:36:33 2025 -0700
@@ -317,6 +317,9 @@
 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;
--- a/src/njs_chb.c	Wed May 14 18:00:23 2025 -0700
+++ b/src/njs_chb.c	Wed May 14 19:36:33 2025 -0700
@@ -251,7 +251,11 @@
 
     while (n != NULL) {
         next = n->next;
-        chain->free(chain->pool, n);
+
+        if (chain->free != NULL) {
+            chain->free(chain->pool, n);
+        }
+
         n = next;
     }
 }