]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
This is a followup to r2263. Use offsetof.
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 27 Feb 2012 15:38:34 +0000 (15:38 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 27 Feb 2012 15:38:34 +0000 (15:38 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@2264

VEX/pub/libvex.h

index 5598fcc1e92a7bfb708b0b81b417285a7294bd57..a259fcce8ec4946e2dc873a140706e96dcf15288 100644 (file)
@@ -345,7 +345,7 @@ extern void   private_LibVEX_alloc_OOM(void) __attribute__((noreturn));
 
 static inline void* LibVEX_Alloc ( Int nbytes )
 {
-   struct 
+   struct align {
       char c;
       union {
          char c;
@@ -361,7 +361,7 @@ static inline void* LibVEX_Alloc ( Int nbytes )
          void *pto;
          void (*ptf)(void);
       } x;
-   } s;
+   };
 
 #if 0
   /* Nasty debugging hack, do not use. */
@@ -370,7 +370,7 @@ static inline void* LibVEX_Alloc ( Int nbytes )
    HChar* curr;
    HChar* next;
    Int    ALIGN;
-   ALIGN  = ((Int) ((UChar *)&s.x - (UChar *)&s)) - 1;
+   ALIGN  = offsetof(struct align,x) - 1;
    nbytes = (nbytes + ALIGN) & ~ALIGN;
    curr   = private_LibVEX_alloc_curr;
    next   = curr + nbytes;