summaryrefslogtreecommitdiff
path: root/contrib/xml2/xpath.c
diff options
context:
space:
mode:
authorTom Lane2008-05-04 16:42:41 +0000
committerTom Lane2008-05-04 16:42:41 +0000
commit45173ae24e308061c008f77996f3edbebe0e4dc2 (patch)
tree9dd9bd3cc11648b13dd0ccee488014421adbe274 /contrib/xml2/xpath.c
parent0ff74f03b153abfe4cc10abe7be5a13cdbcac782 (diff)
Use new cstring/text conversion functions in some additional places.
These changes assume that the varchar and xml data types are represented the same as text. (I did not, however, accept the portions of the proposed patch that wanted to assume bytea is the same as text --- tgl.) Brendan Jurd
Diffstat (limited to 'contrib/xml2/xpath.c')
-rw-r--r--contrib/xml2/xpath.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
index 601733ac87..98865bac7a 100644
--- a/contrib/xml2/xpath.c
+++ b/contrib/xml2/xpath.c
@@ -194,7 +194,6 @@ xml_encode_special_chars(PG_FUNCTION_ARGS)
{
text *tin = PG_GETARG_TEXT_P(0);
text *tout;
- int32 ressize;
xmlChar *ts,
*tt;
@@ -204,10 +203,7 @@ xml_encode_special_chars(PG_FUNCTION_ARGS)
pfree(ts);
- ressize = strlen((char *) tt);
- tout = (text *) palloc(ressize + VARHDRSZ);
- memcpy(VARDATA(tout), tt, ressize);
- SET_VARSIZE(tout, ressize + VARHDRSZ);
+ tout = cstring_to_text((char *) tt);
xmlFree(tt);
@@ -306,14 +302,7 @@ pgxmlNodeSetToText(xmlNodeSetPtr nodeset,
xmlChar *
pgxml_texttoxmlchar(text *textstring)
{
- xmlChar *res;
- int32 txsize;
-
- txsize = VARSIZE(textstring) - VARHDRSZ;
- res = (xmlChar *) palloc(txsize + 1);
- memcpy((char *) res, VARDATA(textstring), txsize);
- res[txsize] = '\0';
- return res;
+ return (xmlChar *) text_to_cstring(textstring);
}
/* Public visible XPath functions */
@@ -577,7 +566,6 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
xmlChar * plainsep)
{
xmlChar *xpresstr;
- int32 ressize;
text *xpres;
if (res == NULL)
@@ -604,10 +592,7 @@ pgxml_result_to_text(xmlXPathObjectPtr res,
/* Now convert this result back to text */
- ressize = strlen((char *) xpresstr);
- xpres = (text *) palloc(ressize + VARHDRSZ);
- memcpy(VARDATA(xpres), xpresstr, ressize);
- SET_VARSIZE(xpres, ressize + VARHDRSZ);
+ xpres = cstring_to_text((char *) xpresstr);
/* Free various storage */
xmlCleanupParser();