|
7 | 7 | * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group |
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
10 | | - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.23 2007/01/2711:48:31 petere Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.24 2007/01/2714:50:51 petere Exp $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
|
23 | 23 | * else does. |
24 | 24 | */ |
25 | 25 |
|
| 26 | +/* |
| 27 | + * Note on memory management: Via callbacks, libxml is told to use |
| 28 | + * palloc and friends for memory management. Sometimes, libxml |
| 29 | + * allocates global structures in the hope that it can reuse them |
| 30 | + * later on, but if "later" is much later, the memory context |
| 31 | + * management of PostgreSQL will have blown those structures away |
| 32 | + * without telling libxml about it. Therefore, it is important to |
| 33 | + * call xmlCleanupParser() or perhaps some other cleanup function |
| 34 | + * after using such functions, for example something from |
| 35 | + * libxml/parser.h or libxml/xmlsave.h. Unfortunately, you cannot |
| 36 | + * readily tell from the API documentation when that happens, so |
| 37 | + * careful evaluation is necessary when introducing new libxml APIs |
| 38 | + * here. |
| 39 | + */ |
| 40 | + |
26 | 41 | #include"postgres.h" |
27 | 42 |
|
28 | 43 | #ifdefUSE_LIBXML |
|
31 | 46 | #include<libxml/tree.h> |
32 | 47 | #include<libxml/uri.h> |
33 | 48 | #include<libxml/xmlerror.h> |
34 | | -#include<libxml/xmlsave.h> |
35 | 49 | #include<libxml/xmlwriter.h> |
36 | 50 | #endif/* USE_LIBXML */ |
37 | 51 |
|
|
54 | 68 | staticStringInfoxml_err_buf=NULL; |
55 | 69 |
|
56 | 70 | staticvoidxml_init(void); |
57 | | -#ifdefNOT_USED |
58 | 71 | staticvoid*xml_palloc(size_tsize); |
59 | 72 | staticvoid*xml_repalloc(void*ptr,size_tsize); |
60 | 73 | staticvoidxml_pfree(void*ptr); |
61 | 74 | staticchar*xml_pstrdup(constchar*string); |
62 | | -#endif |
63 | 75 | staticvoidxml_ereport(intlevel,intsqlcode, |
64 | 76 | constchar*msg); |
65 | 77 | staticvoidxml_errorHandler(void*ctxt,constchar*msg, ...); |
@@ -782,14 +794,8 @@ xml_init(void) |
782 | 794 | /* Now that xml_err_buf exists, safe to call xml_errorHandler */ |
783 | 795 | xmlSetGenericErrorFunc(NULL,xml_errorHandler); |
784 | 796 |
|
785 | | -#ifdefNOT_USED |
786 | | -/* |
787 | | - * FIXME: This doesn't work because libxml assumes that whatever |
788 | | - * libxml allocates, only libxml will free, so we can't just drop |
789 | | - * memory contexts behind it. This needs to be refined. |
790 | | - */ |
791 | 797 | xmlMemSetup(xml_pfree,xml_palloc,xml_repalloc,xml_pstrdup); |
792 | | -#endif |
| 798 | + |
793 | 799 | xmlInitParser(); |
794 | 800 | LIBXML_TEST_VERSION; |
795 | 801 | } |
@@ -1098,7 +1104,6 @@ xml_text2xmlChar(text *in) |
1098 | 1104 | } |
1099 | 1105 |
|
1100 | 1106 |
|
1101 | | -#ifdefNOT_USED |
1102 | 1107 | /* |
1103 | 1108 | * Wrappers for memory management functions |
1104 | 1109 | */ |
@@ -1128,7 +1133,6 @@ xml_pstrdup(const char *string) |
1128 | 1133 | { |
1129 | 1134 | returnpstrdup(string); |
1130 | 1135 | } |
1131 | | -#endif/* NOT_USED */ |
1132 | 1136 |
|
1133 | 1137 |
|
1134 | 1138 | /* |
|