summaryrefslogtreecommitdiff
path: root/contrib/intarray/_int_bool.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/intarray/_int_bool.c')
-rw-r--r--contrib/intarray/_int_bool.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c
index 2344d0b50b..ef9430901d 100644
--- a/contrib/intarray/_int_bool.c
+++ b/contrib/intarray/_int_bool.c
@@ -765,9 +765,7 @@ querytree(PG_FUNCTION_ARGS)
if (len == 0)
{
- res = (text *) palloc(1 + VARHDRSZ);
- SET_VARSIZE(res, 1 + VARHDRSZ);
- *((char *) VARDATA(res)) = 'T';
+ res = cstring_to_text("T");
}
else
{
@@ -776,12 +774,9 @@ querytree(PG_FUNCTION_ARGS)
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
*(nrm.cur) = '\0';
infix(&nrm, true);
-
- res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
- SET_VARSIZE(res, nrm.cur - nrm.buf + VARHDRSZ);
- memcpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
+ res = cstring_to_text_with_len(nrm.buf, nrm.cur - nrm.buf);
}
pfree(q);
- PG_RETURN_POINTER(res);
+ PG_RETURN_TEXT_P(res);
}