[cairo] [PATCH] remove zero sized array in tor-rasterizer

Jeff Muizelaar jeff at infidigm.net
Mon Feb 9 13:31:08 PST 2009


Joonas,

MSVC doesn't support zero sized arrays very well. For example, zero
sized arrays in arrays. The attached patch fixes compliation on MSVC.
Unfortunately it makes thing uglier.

-Jeff
-------------- next part --------------
commit af94c81abd7fbed083810fee1064102dd0d756dc
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Mon Feb 9 16:03:40 2009 -0500

    Remove zero size data array for compilation with MSVC

diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c
index 087f010..4abafc4 100644
--- a/src/cairo-tor-scan-converter.c
+++ b/src/cairo-tor-scan-converter.c
@@ -320,7 +320,6 @@ struct _pool_chunk {
     struct _pool_chunk *prev_chunk;
 
     /* Actual data starts here.	 Well aligned for pointers. */
-    unsigned char data[0];
 };
 
 /* A memory pool.  This is supposed to be embedded on the stack or
@@ -623,7 +622,7 @@ _pool_alloc_from_new_chunk(
     }
     pool->current = chunk;
 
-    obj = &chunk->data[chunk->size];
+    obj = ((unsigned char*)chunk + sizeof(*chunk) + chunk->size);
     chunk->size += size;
     return obj;
 }
@@ -642,7 +641,7 @@ pool_alloc(
     struct _pool_chunk *chunk = pool->current;
 
     if (size <= chunk->capacity - chunk->size) {
-	void *obj = &chunk->data[chunk->size];
+	void *obj = ((unsigned char*)chunk + sizeof(*chunk) + chunk->size);
 	chunk->size += size;
 	return obj;
     }


More information about the cairo mailing list