mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
Change winding_t, winding_accu_t and brush_t to use flexible array members rather than fixed-sized arrays.
The arrays were always meant to be variably sized, and objects are only ever allocated dynamically. Object size computations are simplified with this change. Flexible arrays were introduced in C99, so this change means that we will require a C99-conforming compiler henceforth.
This commit is contained in:
parent
4ace24c00a
commit
f061ce9990
4 changed files with 7 additions and 7 deletions
|
@ -68,7 +68,7 @@ winding_t *AllocWinding( int points ){
|
|||
c_peak_windings = c_active_windings;
|
||||
}
|
||||
}
|
||||
s = sizeof( vec_t ) * 3 * points + sizeof( int );
|
||||
s = sizeof( *w ) + points * sizeof( *w->p );
|
||||
w = safe_malloc( s );
|
||||
memset( w, 0, s );
|
||||
return w;
|
||||
|
@ -96,7 +96,7 @@ winding_accu_t *AllocWindingAccu( int points ){
|
|||
c_peak_windings = c_active_windings;
|
||||
}
|
||||
}
|
||||
s = sizeof(*w) + (points > 4 ? sizeof(vec3_accu_t) * (points - 4) : 0);
|
||||
s = sizeof( *w ) + points * sizeof( *w->p );
|
||||
w = safe_malloc( s );
|
||||
memset( w, 0, s );
|
||||
return w;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
typedef struct
|
||||
{
|
||||
int numpoints;
|
||||
vec3_t p[4]; // variable sized
|
||||
vec3_t p[];
|
||||
} winding_t;
|
||||
|
||||
#define MAX_POINTS_ON_WINDING 64
|
||||
|
@ -65,7 +65,7 @@ void pw( winding_t *w );
|
|||
typedef struct
|
||||
{
|
||||
int numpoints;
|
||||
vec3_accu_t p[4]; // variable sized
|
||||
vec3_accu_t p[];
|
||||
} winding_accu_t;
|
||||
|
||||
winding_accu_t *BaseWindingForPlaneAccu( vec3_t normal, vec_t dist );
|
||||
|
|
|
@ -93,7 +93,7 @@ brush_t *AllocBrush( int numSides ){
|
|||
brush_t *bb;
|
||||
size_t c;
|
||||
|
||||
c = sizeof(*bb) + (numSides > 6 ? sizeof(side_t)*(numSides - 6) : 0);
|
||||
c = sizeof( *bb ) + sizeof( *bb->sides ) * numSides;
|
||||
bb = safe_malloc( c );
|
||||
memset( bb, 0, c );
|
||||
if ( numthreads == 1 ) {
|
||||
|
@ -1023,7 +1023,7 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back )
|
|||
for ( i = 0 ; i < 2 ; i++ )
|
||||
{
|
||||
b[i] = AllocBrush( brush->numsides + 1 );
|
||||
memcpy( b[i], brush, sizeof( brush_t ) - sizeof( brush->sides ) );
|
||||
memcpy( b[i], brush, sizeof( brush_t ) );
|
||||
b[i]->numsides = 0;
|
||||
b[i]->next = NULL;
|
||||
b[i]->original = brush->original;
|
||||
|
|
|
@ -893,7 +893,7 @@ typedef struct brush_s
|
|||
vec3_t mins, maxs;
|
||||
int numsides;
|
||||
|
||||
side_t sides[ 6 ]; /* variably sized */
|
||||
side_t sides[]; /* variably sized */
|
||||
}
|
||||
brush_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue