Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit915abb3

Browse files
committed
Reactivate libxml memory management via palloc, now that I think I've
classified the conditions under which this is safe to do (see sourcecode comment).
1 parentd3be7fa commit915abb3

File tree

1 file changed

+17
-13
lines changed
  • src/backend/utils/adt

1 file changed

+17
-13
lines changed

‎src/backend/utils/adt/xml.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -23,6 +23,21 @@
2323
* else does.
2424
*/
2525

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+
2641
#include"postgres.h"
2742

2843
#ifdefUSE_LIBXML
@@ -31,7 +46,6 @@
3146
#include<libxml/tree.h>
3247
#include<libxml/uri.h>
3348
#include<libxml/xmlerror.h>
34-
#include<libxml/xmlsave.h>
3549
#include<libxml/xmlwriter.h>
3650
#endif/* USE_LIBXML */
3751

@@ -54,12 +68,10 @@
5468
staticStringInfoxml_err_buf=NULL;
5569

5670
staticvoidxml_init(void);
57-
#ifdefNOT_USED
5871
staticvoid*xml_palloc(size_tsize);
5972
staticvoid*xml_repalloc(void*ptr,size_tsize);
6073
staticvoidxml_pfree(void*ptr);
6174
staticchar*xml_pstrdup(constchar*string);
62-
#endif
6375
staticvoidxml_ereport(intlevel,intsqlcode,
6476
constchar*msg);
6577
staticvoidxml_errorHandler(void*ctxt,constchar*msg, ...);
@@ -782,14 +794,8 @@ xml_init(void)
782794
/* Now that xml_err_buf exists, safe to call xml_errorHandler */
783795
xmlSetGenericErrorFunc(NULL,xml_errorHandler);
784796

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-
*/
791797
xmlMemSetup(xml_pfree,xml_palloc,xml_repalloc,xml_pstrdup);
792-
#endif
798+
793799
xmlInitParser();
794800
LIBXML_TEST_VERSION;
795801
}
@@ -1098,7 +1104,6 @@ xml_text2xmlChar(text *in)
10981104
}
10991105

11001106

1101-
#ifdefNOT_USED
11021107
/*
11031108
* Wrappers for memory management functions
11041109
*/
@@ -1128,7 +1133,6 @@ xml_pstrdup(const char *string)
11281133
{
11291134
returnpstrdup(string);
11301135
}
1131-
#endif/* NOT_USED */
11321136

11331137

11341138
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp