clean up newbytes and newints to remove offset macro. Reference: /n/atom/patch/applied/tlshandnit Date: Thu Sep 24 04:48:40 CES 2015 Signed-off-by: quanstro@quanstro.net --- /sys/src/libsec/port/tlshand.c Thu Sep 24 04:48:12 2015 +++ /sys/src/libsec/port/tlshand.c Thu Sep 24 04:48:14 2015 @@ -34,7 +34,7 @@ typedef struct Ints{ int len; - int data[1]; // [len] + int data[]; } Ints; typedef struct Algs{ @@ -2896,14 +2896,12 @@ return (p[0]<<8)|p[1]; } -#define OFFSET(x, s) offsetof(s, x) - static Bytes* newbytes(int len) { Bytes* ans; - ans = (Bytes*)emalloc(OFFSET(data[0], Bytes) + len); + ans = emalloc(sizeof(*ans) + len*sizeof(ans->data[0])); ans->len = len; return ans; } @@ -2933,7 +2931,7 @@ { Ints* ans; - ans = (Ints*)emalloc(OFFSET(data[0], Ints) + len*sizeof(int)); + ans = emalloc(sizeof(*ans) + len*sizeof(ans->data[0])); ans->len = len; return ans; }