AllocWinding: fix handling of compiler enforced alignment of double
authorRudolf Polzer <divverent@xonotic.org>
Thu, 8 Dec 2011 11:20:56 +0000 (12:20 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 8 Dec 2011 11:20:56 +0000 (12:20 +0100)
tools/quake3/common/polylib.c
tools/quake3/common/polylib.h

index af4b98e..1d59dd4 100644 (file)
@@ -67,7 +67,7 @@ winding_t     *AllocWinding (int points)
                if (c_active_windings > c_peak_windings)
                        c_peak_windings = c_active_windings;
        }
-       s = sizeof(vec_t)*3*points + sizeof(int);
+       s = sizeof(*w) + (points ? sizeof(w->p[0])*(points-1) : 0);
        w = safe_malloc (s);
        memset (w, 0, s); 
        return w;
@@ -95,7 +95,7 @@ winding_accu_t *AllocWindingAccu(int points)
                if (c_active_windings > c_peak_windings)
                        c_peak_windings = c_active_windings;
        }
-       s = sizeof(vec_accu_t) * 3 * points + sizeof(int);
+       s = sizeof(*w) + (points ? sizeof(w->p[0])*(points-1) : 0);
        w = safe_malloc(s);
        memset(w, 0, s); 
        return w;
index 9750180..07e3783 100644 (file)
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 typedef struct
 {
        int             numpoints;
-       vec3_t  p[4];           // variable sized
+       vec3_t  p[1];           // variable sized
 } winding_t;
 
 #define        MAX_POINTS_ON_WINDING   512
@@ -67,7 +67,7 @@ void pw(winding_t *w);
 typedef struct
 {
        int             numpoints;
-       vec3_accu_t     p[4]; // variable sized
+       vec3_accu_t     p[1]; // variable sized
 } winding_accu_t;
 
 winding_accu_t *BaseWindingForPlaneAccu(vec3_t normal, vec_t dist);