CLEANUP: Use `isttest()` and `istfree()`
This adjusts a few locations to make use of `isttest()` and `istfree()`.
diff --git a/src/fcgi-app.c b/src/fcgi-app.c
index 5d26580..8472cf5 100644
--- a/src/fcgi-app.c
+++ b/src/fcgi-app.c
@@ -838,9 +838,9 @@
}
if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code))
goto out;
- free(curapp->docroot.ptr);
+ istfree(&curapp->docroot);
curapp->docroot = ist2(strdup(args[1]), strlen(args[1]));
- if (!curapp->docroot.ptr) {
+ if (!isttest(curapp->docroot)) {
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
}
@@ -871,9 +871,9 @@
}
if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code))
goto out;
- free(curapp->index.ptr);
+ istfree(&curapp->index);
curapp->index = ist2(strdup(args[1]), strlen(args[1]));
- if (!curapp->index.ptr) {
+ if (!isttest(curapp->index)) {
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
}
@@ -1070,8 +1070,8 @@
struct fcgi_rule_conf *rule, *back;
free(curapp->name);
- free(curapp->docroot.ptr);
- free(curapp->index.ptr);
+ istfree(&curapp->docroot);
+ istfree(&curapp->index);
regex_free(curapp->pathinfo_re);
free(curapp->conf.file);
diff --git a/src/hlua.c b/src/hlua.c
index d8e538b..4043e29 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -3889,7 +3889,7 @@
lua_settable(L, -3);
path = http_get_path(htx_sl_req_uri(sl));
- if (path.ptr) {
+ if (isttest(path)) {
char *p, *q, *end;
p = path.ptr;
diff --git a/src/hpack-dec.c b/src/hpack-dec.c
index b4d8f0d..fa25ac4 100644
--- a/src/hpack-dec.c
+++ b/src/hpack-dec.c
@@ -191,7 +191,7 @@
}
value = hpack_alloc_string(tmp, idx, hpack_idx_to_value(dht, idx));
- if (!value.ptr) {
+ if (!isttest(value)) {
hpack_debug_printf("##ERR@%d##\n", __LINE__);
ret = -HPACK_ERR_TOO_LARGE;
goto leave;
@@ -202,7 +202,7 @@
if (!name.len) {
name = hpack_alloc_string(tmp, idx, hpack_idx_to_name(dht, idx));
- if (!name.ptr) {
+ if (!isttest(name)) {
hpack_debug_printf("##ERR@%d##\n", __LINE__);
ret = -HPACK_ERR_TOO_LARGE;
goto leave;
@@ -412,7 +412,7 @@
if (!name.len) {
name = hpack_alloc_string(tmp, idx, hpack_idx_to_name(dht, idx));
- if (!name.ptr) {
+ if (!isttest(name)) {
hpack_debug_printf("##ERR@%d##\n", __LINE__);
ret = -HPACK_ERR_TOO_LARGE;
goto leave;
@@ -444,7 +444,7 @@
}
hpack_debug_printf("\e[1;34m%s\e[0m: ",
- name.ptr ? istpad(trash.area, name).ptr : h2_phdr_to_str(name.len));
+ isttest(name) ? istpad(trash.area, name).ptr : h2_phdr_to_str(name.len));
hpack_debug_printf("\e[1;35m%s\e[0m [mustidx=%d, used=%d] [n=(%p,%d) v=(%p,%d)]\n",
istpad(trash.area, value).ptr, must_index,
diff --git a/src/http_act.c b/src/http_act.c
index 9bfa7eb..7c16c33 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -56,8 +56,7 @@
{
struct logformat_node *lf, *lfb;
- if (rule->arg.http.str.ptr)
- free(rule->arg.http.str.ptr);
+ istfree(&rule->arg.http.str);
if (rule->arg.http.re)
regex_free(rule->arg.http.re);
list_for_each_entry_safe(lf, lfb, &rule->arg.http.fmt, list) {
@@ -1257,7 +1256,7 @@
cur_arg++;
if (!parse_logformat_string(args[cur_arg], px, &rule->arg.http.fmt, LOG_OPT_HTTP, cap, err)) {
- free(rule->arg.http.str.ptr);
+ istfree(&rule->arg.http.str);
return ACT_RET_PRS_ERR;
}
@@ -1351,7 +1350,7 @@
cur_arg++;
if (!(rule->arg.http.re = regex_comp(args[cur_arg], 1, 1, err))) {
- free(rule->arg.http.str.ptr);
+ istfree(&rule->arg.http.str);
return ACT_RET_PRS_ERR;
}
@@ -1366,7 +1365,7 @@
cur_arg++;
if (!parse_logformat_string(args[cur_arg], px, &rule->arg.http.fmt, LOG_OPT_HTTP, cap, err)) {
- free(rule->arg.http.str.ptr);
+ istfree(&rule->arg.http.str);
regex_free(rule->arg.http.re);
return ACT_RET_PRS_ERR;
}
@@ -1829,7 +1828,7 @@
free(lf->arg);
free(lf);
}
- free(hdr->name.ptr);
+ istfree(&hdr->name);
free(hdr);
}
free(rule->arg.http_return.hdrs);
@@ -2295,7 +2294,7 @@
free(lf->arg);
free(lf);
}
- free(hdr->name.ptr);
+ istfree(&hdr->name);
free(hdr);
}
}
@@ -2366,7 +2365,7 @@
free(lf->arg);
free(lf);
}
- free(hdr->name.ptr);
+ istfree(&hdr->name);
free(hdr);
}
}
@@ -2444,7 +2443,7 @@
free(lf->arg);
free(lf);
}
- free(hdr->name.ptr);
+ istfree(&hdr->name);
free(hdr);
}
free(hdrs);
diff --git a/src/http_ana.c b/src/http_ana.c
index e268d4c..a970660 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -2503,7 +2503,7 @@
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
/* build message using path */
- if (path.ptr) {
+ if (isttest(path)) {
if (rule->flags & REDIRECT_FLAG_DROP_QS) {
int qs = 0;
while (qs < path.len) {
@@ -2551,7 +2551,7 @@
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
/* build message using path */
- if (path.ptr) {
+ if (isttest(path)) {
if (rule->flags & REDIRECT_FLAG_DROP_QS) {
int qs = 0;
while (qs < path.len) {
@@ -4252,7 +4252,7 @@
htx = htxbuf(&req->buf);
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
- if (!path.ptr)
+ if (!isttest(path))
return;
if (!chunk_memcat(&trash, path.ptr, path.len))
diff --git a/src/http_fetch.c b/src/http_fetch.c
index dbbb5ec..9113b5e 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -987,7 +987,7 @@
sl = http_get_stline(htx);
path = iststop(http_get_path(htx_sl_req_uri(sl)), '?');
- if (!path.ptr)
+ if (!isttest(path))
return 0;
/* OK, we got the '/' ! */
@@ -1028,7 +1028,7 @@
/* now retrieve the path */
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
- if (path.ptr) {
+ if (isttest(path)) {
size_t len;
for (len = 0; len < path.len && *(path.ptr + len) != '?'; len++)
@@ -1074,7 +1074,7 @@
/* now retrieve the path */
sl = http_get_stline(htx);
path = http_get_path(htx_sl_req_uri(sl));
- if (path.ptr) {
+ if (isttest(path)) {
size_t len;
for (len = 0; len < path.len && *(path.ptr + len) != '?'; len++)
@@ -1422,7 +1422,7 @@
path.len = ptr - path.ptr;
path = http_get_path(path);
- if (!path.ptr)
+ if (!isttest(path))
return 0;
smp->data.u.str.area = path.ptr;
diff --git a/src/http_htx.c b/src/http_htx.c
index 8157eb5..0e68695 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -111,7 +111,7 @@
if (blk) {
char *p;
- if (!ctx->value.ptr)
+ if (!isttest(ctx->value))
goto rescan_hdr;
if (full)
goto next_blk;
@@ -309,7 +309,7 @@
uri = htx_sl_req_uri(sl);
p = http_get_path(uri);
- if (!p.ptr)
+ if (!isttest(p))
p = uri;
while (plen < p.len && *(p.ptr + plen) != '?')
plen++;
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 2e2dbf9..7260629 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -2853,7 +2853,7 @@
entry->name.len = strlen(to);
if (!entry->node.key || !entry->name.ptr) {
free(entry->node.key);
- free(entry->name.ptr);
+ istfree(&entry->name);
free(entry);
memprintf(err, "out of memory");
return -1;
@@ -2873,7 +2873,7 @@
ebpt_delete(node);
entry = container_of(node, struct h1_hdr_entry, node);
free(entry->node.key);
- free(entry->name.ptr);
+ istfree(&entry->name);
free(entry);
node = next;
}