Commit 0e70b793 authored by mrowe@apple.com's avatar mrowe@apple.com

Work around <rdar://problem/6833240> by relying on static initialization to zero the entire struct.

This removes the need for us to explicitly initialize all of the members, which have a tendency
to change in meaning and number between versions of libxml2.

Reviewed by Sam Weinig.

* dom/XMLTokenizerLibxml2.cpp:
(WebCore::):
(WebCore::sharedXHTMLEntity):
(WebCore::getXHTMLEntity):

git-svn-id: svn://svn.chromium.org/blink/trunk@42945 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2a996d8a
2009-04-28 Mark Rowe <mrowe@apple.com>
Reviewed by Sam Weinig.
Work around <rdar://problem/6833240> by relying on static initialization to zero the entire struct.
This removes the need for us to explicitly initialize all of the members, which have a tendency
to change in meaning and number between versions of libxml2.
* dom/XMLTokenizerLibxml2.cpp:
(WebCore::):
(WebCore::sharedXHTMLEntity):
(WebCore::getXHTMLEntity):
2009-04-28 Steve Falkenburg <sfalken@apple.com> 2009-04-28 Steve Falkenburg <sfalken@apple.com>
Fix linker warning by specifying /NODEFAULTLIB:LIBCMT for QTMovieWin. Fix linker warning by specifying /NODEFAULTLIB:LIBCMT for QTMovieWin.
...@@ -1064,19 +1064,22 @@ static void normalErrorHandler(void* closure, const char* message, ...) ...@@ -1064,19 +1064,22 @@ static void normalErrorHandler(void* closure, const char* message, ...)
va_end(args); va_end(args);
} }
// Using a global variable entity and marking it XML_INTERNAL_PREDEFINED_ENTITY is // Using a static entity and marking it XML_INTERNAL_PREDEFINED_ENTITY is
// a hack to avoid malloc/free. Using a global variable like this could cause trouble // a hack to avoid malloc/free. Using a global variable like this could cause trouble
// if libxml implementation details were to change // if libxml implementation details were to change
static xmlChar sharedXHTMLEntityResult[5] = {0,0,0,0,0}; static xmlChar sharedXHTMLEntityResult[5] = {0, 0, 0, 0, 0};
static xmlEntity sharedXHTMLEntity = {
0, XML_ENTITY_DECL, 0, 0, 0, 0, 0, 0, 0, static xmlEntityPtr sharedXHTMLEntity()
sharedXHTMLEntityResult, sharedXHTMLEntityResult, 0, {
XML_INTERNAL_PREDEFINED_ENTITY, 0, 0, 0, 0, 0, static xmlEntity entity;
#if LIBXML_VERSION >= 20627 if (!entity.type) {
// xmlEntity gained an extra member in 2.6.27. entity.type = XML_ENTITY_DECL;
1 entity.orig = sharedXHTMLEntityResult;
#endif entity.content = sharedXHTMLEntityResult;
}; entity.etype = XML_INTERNAL_PREDEFINED_ENTITY;
}
return &entity;
}
static xmlEntityPtr getXHTMLEntity(const xmlChar* name) static xmlEntityPtr getXHTMLEntity(const xmlChar* name)
{ {
...@@ -1086,11 +1089,12 @@ static xmlEntityPtr getXHTMLEntity(const xmlChar* name) ...@@ -1086,11 +1089,12 @@ static xmlEntityPtr getXHTMLEntity(const xmlChar* name)
CString value = String(&c, 1).utf8(); CString value = String(&c, 1).utf8();
ASSERT(value.length() < 5); ASSERT(value.length() < 5);
sharedXHTMLEntity.length = value.length(); xmlEntityPtr entity = sharedXHTMLEntity();
sharedXHTMLEntity.name = name; entity->length = value.length();
memcpy(sharedXHTMLEntityResult, value.data(), sharedXHTMLEntity.length + 1); entity->name = name;
memcpy(sharedXHTMLEntityResult, value.data(), entity->length + 1);
return &sharedXHTMLEntity; return entity;
} }
static xmlEntityPtr getEntityHandler(void* closure, const xmlChar* name) static xmlEntityPtr getEntityHandler(void* closure, const xmlChar* name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment