Merge pull request #582 from tkoeppe/flexi

Use flexible array members
This commit is contained in:
Timothee "TTimo" Besset 2018-01-22 08:36:52 -06:00 committed by GitHub
commit 322935310e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View file

@ -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;

View file

@ -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 );

View file

@ -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;

View file

@ -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;