use offsetof( type, flexible_array_member[size] ) semantics
This commit is contained in:
parent
99bae99b36
commit
a626907ba9
|
|
@ -449,17 +449,10 @@ winding_t *BaseWindingForPlane( vec3_t normal, vec_t dist ){
|
|||
==================
|
||||
*/
|
||||
winding_t *CopyWinding( winding_t *w ){
|
||||
size_t size;
|
||||
winding_t *c;
|
||||
|
||||
if ( !w ) {
|
||||
Error( "CopyWinding: winding is NULL" );
|
||||
}
|
||||
|
||||
c = AllocWinding( w->numpoints );
|
||||
size = offsetof( winding_t, p ) + sizeof( *w->p ) * w->numpoints;
|
||||
memcpy( c, w, size );
|
||||
return c;
|
||||
return memcpy( AllocWinding( w->numpoints ), w, offsetof( winding_t, p[w->numpoints] ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -157,21 +157,15 @@ void FreeBrushList( brush_t *brushes ){
|
|||
*/
|
||||
|
||||
brush_t *CopyBrush( brush_t *brush ){
|
||||
brush_t *newBrush;
|
||||
size_t size;
|
||||
int i;
|
||||
|
||||
|
||||
/* copy brush */
|
||||
size = offsetof( brush_t, sides ) + sizeof( *brush->sides ) * brush->numsides;
|
||||
newBrush = AllocBrush( brush->numsides );
|
||||
memcpy( newBrush, brush, size );
|
||||
brush_t *newBrush = AllocBrush( brush->numsides );
|
||||
memcpy( newBrush, brush, offsetof( brush_t, sides[brush->numsides] ) );
|
||||
|
||||
/* ydnar: nuke linked list */
|
||||
newBrush->next = NULL;
|
||||
|
||||
/* copy sides */
|
||||
for ( i = 0; i < brush->numsides; i++ )
|
||||
for ( int i = 0; i < brush->numsides; i++ )
|
||||
{
|
||||
if ( brush->sides[ i ].winding != NULL ) {
|
||||
newBrush->sides[ i ].winding = CopyWinding( brush->sides[ i ].winding );
|
||||
|
|
|
|||
|
|
@ -1421,7 +1421,7 @@ void CreatePassages( int portalnum ){
|
|||
/* ydnar: prefer correctness to stack overflow */
|
||||
//% memcpy( &in, p->winding, (int)((fixedWinding_t *)0)->points[p->winding->numpoints] );
|
||||
if ( p->winding->numpoints <= MAX_POINTS_ON_FIXED_WINDING ) {
|
||||
memcpy( &in, p->winding, offsetof( fixedWinding_t, points ) + sizeof( *p->winding->points ) * p->winding->numpoints );
|
||||
memcpy( &in, p->winding, offsetof( fixedWinding_t, points[p->winding->numpoints] ) );
|
||||
}
|
||||
else{
|
||||
memcpy( &in, p->winding, sizeof( fixedWinding_t ) );
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user