gcc 11: pass constant to offsetof
This commit is contained in:
parent
4ba0e99d3f
commit
c9570260fa
|
|
@ -230,7 +230,10 @@ polylib::CopyWinding(const winding_t * w)
|
|||
int size;
|
||||
winding_t *c;
|
||||
|
||||
size = offsetof(winding_t, p[w->numpoints]);
|
||||
//size = offsetof(winding_t, p[w->numpoints]);
|
||||
size = offsetof(winding_t, p[0]);
|
||||
size += w->numpoints * sizeof(w->p[0]);
|
||||
|
||||
c = static_cast<winding_t *>(malloc(size));
|
||||
memcpy(c, w, size);
|
||||
return c;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ AllocMem(int Type, int cElements, bool fZero)
|
|||
if (cElements > MAX_POINTS_ON_WINDING)
|
||||
Error("Too many points (%d) on winding (%s)", cElements, __func__);
|
||||
|
||||
cSize = offsetof(winding_t, points[cElements]) + sizeof(int);
|
||||
//cSize = offsetof(winding_t, points[cElements]) + sizeof(int);
|
||||
cSize = offsetof(winding_t, points[0]);
|
||||
cSize += cElements * sizeof(static_cast<winding_t*>(nullptr)->points[0]);
|
||||
cSize += sizeof(int);
|
||||
|
||||
// Set cElements to 1 so bookkeeping works OK
|
||||
cElements = 1;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ CopyWinding(const winding_t *w)
|
|||
winding_t *c;
|
||||
|
||||
c = (winding_t *)AllocMem(WINDING, w->numpoints, false);
|
||||
size = offsetof(winding_t, points[w->numpoints]);
|
||||
//size = offsetof(winding_t, points[w->numpoints]);
|
||||
size = offsetof(winding_t, points[0]);
|
||||
size += w->numpoints * sizeof(w->points[0]);
|
||||
memcpy(c, w, size);
|
||||
|
||||
return c;
|
||||
|
|
|
|||
10
vis/vis.cc
10
vis/vis.cc
|
|
@ -127,7 +127,10 @@ NewWinding(int points)
|
|||
if (points > MAX_WINDING)
|
||||
Error("%s: %i points", __func__, points);
|
||||
|
||||
size = offsetof(winding_t, points[points]);
|
||||
//size = offsetof(winding_t, points[points]);
|
||||
size = offsetof(winding_t, points[0]);
|
||||
size += points * sizeof(w->points[0]);
|
||||
|
||||
w = static_cast<winding_t *>(malloc(size));
|
||||
memset(w, 0, size);
|
||||
|
||||
|
|
@ -178,7 +181,10 @@ CopyWinding(const winding_t * w)
|
|||
int size;
|
||||
winding_t *c;
|
||||
|
||||
size = offsetof(winding_t, points[w->numpoints]);
|
||||
//size = offsetof(winding_t, points[w->numpoints]);
|
||||
size = offsetof(winding_t, points[0]);
|
||||
size += w->numpoints * sizeof(w->points[0]);
|
||||
|
||||
c = static_cast<winding_t *>(malloc(size));
|
||||
memcpy(c, w, size);
|
||||
return c;
|
||||
|
|
|
|||
Loading…
Reference in New Issue