Author: jmb
Date: Sun Apr 1 04:14:13 2012
New Revision: 13785
URL:
http://source.netsurf-browser.org?rev=13785&view=rev
Log:
Force dom_string to have maximal alignment requirements.
Make it clear that dom_string_internal extends it
Modified:
trunk/libdom/include/dom/core/string.h
trunk/libdom/src/core/string.c
Modified: trunk/libdom/include/dom/core/string.h
URL:
http://source.netsurf-browser.org/trunk/libdom/include/dom/core/string.h?...
==============================================================================
--- trunk/libdom/include/dom/core/string.h (original)
+++ trunk/libdom/include/dom/core/string.h Sun Apr 1 04:14:13 2012
@@ -15,10 +15,10 @@
#include <dom/functypes.h>
#include <dom/core/exceptions.h>
-
-typedef struct dom_string {
+typedef struct dom_string dom_string;
+struct dom_string {
uint32_t refcnt;
-} dom_string;
+} _ALIGNED;
/* Claim a reference on a DOM string */
Modified: trunk/libdom/src/core/string.c
URL:
http://source.netsurf-browser.org/trunk/libdom/src/core/string.c?rev=1378...
==============================================================================
--- trunk/libdom/src/core/string.c (original)
+++ trunk/libdom/src/core/string.c Sun Apr 1 04:14:13 2012
@@ -32,8 +32,8 @@
* Strings are reference counted so destruction is performed correctly.
*/
typedef struct dom_string_internal {
- uint32_t refcnt;
-
+ dom_string base;
+
union {
struct {
uint8_t *ptr; /**< Pointer to string data */
@@ -49,7 +49,7 @@
* Empty string, for comparisons against NULL
*/
static const dom_string_internal empty_string = {
- 0,
+ { 0 },
{ { (uint8_t *) "", 0 } },
DOM_STRING_CDATA
};
@@ -58,7 +58,7 @@
{
dom_string_internal *istr = (dom_string_internal *)str;
if (str != NULL) {
- assert(str->refcnt == 0);
+ assert(istr->base.refcnt == 0);
switch (istr->type) {
case DOM_STRING_INTERNED:
if (istr->data.intern != NULL) {
@@ -113,7 +113,7 @@
ret->data.cdata.len = len;
- ret->refcnt = 1;
+ ret->base.refcnt = 1;
ret->type = DOM_STRING_CDATA;
@@ -156,7 +156,7 @@
return DOM_NO_MEM_ERR;
}
- ret->refcnt = 1;
+ ret->base.refcnt = 1;
ret->type = DOM_STRING_INTERNED;
@@ -578,7 +578,7 @@
concat->data.cdata.len = s1len + s2len;
- concat->refcnt = 1;
+ concat->base.refcnt = 1;
concat->type = DOM_STRING_CDATA;
@@ -720,7 +720,7 @@
res->data.cdata.len = tlen + slen;
- res->refcnt = 1;
+ res->base.refcnt = 1;
res->type = DOM_STRING_CDATA;
@@ -819,7 +819,7 @@
res->data.cdata.len = tlen + slen - (b2 - b1);
- res->refcnt = 1;
+ res->base.refcnt = 1;
res->type = DOM_STRING_CDATA;