From 4afa1f6427a1c6ce5f8d4c16fe4083ca812c2101 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 8 Dec 2011 12:20:56 +0100 Subject: [PATCH] AllocWinding: fix handling of compiler enforced alignment of double --- tools/quake3/common/polylib.c | 4 ++-- tools/quake3/common/polylib.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/quake3/common/polylib.c b/tools/quake3/common/polylib.c index af4b98e4..1d59dd4b 100644 --- a/tools/quake3/common/polylib.c +++ b/tools/quake3/common/polylib.c @@ -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; diff --git a/tools/quake3/common/polylib.h b/tools/quake3/common/polylib.h index 9750180e..07e37839 100644 --- a/tools/quake3/common/polylib.h +++ b/tools/quake3/common/polylib.h @@ -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); -- 2.39.2