diff --git a/sys/src/libsec/port/tlshand.c b/sys/src/libsec/port/tlshand.c index bc6506704..bd659e86a 100644 --- a/sys/src/libsec/port/tlshand.c +++ b/sys/src/libsec/port/tlshand.c @@ -2948,8 +2948,6 @@ get16(uchar *p) return (p[0]<<8)|p[1]; } -#define OFFSET(x, s) offsetof(s, x) - static Bytes* newbytes(int len) { @@ -2957,7 +2955,7 @@ newbytes(int len) if(len < 0) abort(); - ans = (Bytes*)emalloc(OFFSET(data[0], Bytes) + len); + ans = emalloc(sizeof(Bytes) + len); ans->len = len; return ans; } @@ -2989,7 +2987,7 @@ newints(int len) if(len < 0 || len > ((uint)-1>>1)/sizeof(int)) abort(); - ans = (Ints*)emalloc(OFFSET(data[0], Ints) + len*sizeof(int)); + ans = emalloc(sizeof(Ints) + len*sizeof(int)); ans->len = len; return ans; } diff --git a/sys/src/libsec/port/x509.c b/sys/src/libsec/port/x509.c index 4e0bf2a9c..1b84ad89a 100644 --- a/sys/src/libsec/port/x509.c +++ b/sys/src/libsec/port/x509.c @@ -3,9 +3,6 @@ #include #include -/* ANSI offsetof, backwards. */ -#define OFFSETOF(a, b) offsetof(b, a) - /*=============================================================*/ /* general ASN1 declarations and parsing * @@ -61,13 +58,13 @@ struct Bytes { struct Ints { int len; - int data[1]; + int data[]; }; struct Bits { int len; /* number of bytes */ int unusedbits; /* unused bits in last byte */ - uchar data[1]; /* most-significant bit first */ + uchar data[]; /* most-significant bit first */ }; struct Tag { @@ -1288,7 +1285,7 @@ newbytes(int len) if(len < 0) abort(); - ans = (Bytes*)emalloc(OFFSETOF(data[0], Bytes) + len); + ans = emalloc(sizeof(Bytes) + len); ans->len = len; return ans; } @@ -1349,7 +1346,7 @@ newints(int len) if(len < 0 || len > ((uint)-1>>1)/sizeof(int)) abort(); - ans = (Ints*)emalloc(OFFSETOF(data[0], Ints) + len*sizeof(int)); + ans = emalloc(sizeof(Ints) + len*sizeof(int)); ans->len = len; return ans; } @@ -1378,7 +1375,7 @@ newbits(int len) if(len < 0) abort(); - ans = (Bits*)emalloc(OFFSETOF(data[0], Bits) + len); + ans = emalloc(sizeof(Bits) + len); ans->len = len; ans->unusedbits = 0; return ans;