Skip to content
Snippets Groups Projects
  • Yorhel's avatar
    2e1838d8
    Get rid of padding in dir struct + use offsetof() to calc needed size · 2e1838d8
    Yorhel authored
    There used to be four bytes of padding in the struct on systems with
    32bit pointers. Moving the pointers down so that they are in between the
    64bit and 32bit fields means that there'll never be any padding.
    
    There may, however, be some extra padding at the end of the struct to
    make the size a multiple of 8. Since we use the name field as a sort of
    "flexible array member", we don't particularly care about that padding
    and just want to allocate enough memory to hold the struct and the name
    field. offsetof() allows us to do that without relying on compiler
    support for flexible array members.
    2e1838d8
    History
    Get rid of padding in dir struct + use offsetof() to calc needed size
    Yorhel authored
    There used to be four bytes of padding in the struct on systems with
    32bit pointers. Moving the pointers down so that they are in between the
    64bit and 32bit fields means that there'll never be any padding.
    
    There may, however, be some extra padding at the end of the struct to
    make the size a multiple of 8. Since we use the name field as a sort of
    "flexible array member", we don't particularly care about that padding
    and just want to allocate enough memory to hold the struct and the name
    field. offsetof() allows us to do that without relying on compiler
    support for flexible array members.