Use offsetof()

Magic has an open coded version of offsetof() which clang complains
about, because it takes the offset of a null pointer. Use offsetof()
instead.
This commit is contained in:
Anton Blanchard 2023-01-08 07:36:16 +11:00 committed by Tim Edwards
parent a4e65afae9
commit c276110daa
2 changed files with 3 additions and 13 deletions

View File

@ -37,6 +37,7 @@
*/
#include <stdio.h>
#include <stddef.h>
#include "utils/utils.h"
#include "utils/malloc.h"
#include "database/database.h"
@ -68,8 +69,8 @@ BPlane *BPNew(void)
/* HASH TABLE */
new->bp_hashTable = IHashInit(4, /* initial buckets */
OFFSET(Element, e_rect), /* key */
OFFSET(Element, e_hashLink),
offsetof(Element, e_rect), /* key */
offsetof(Element, e_hashLink),
IHash4WordKeyHash,
IHash4WordKeyEq);

View File

@ -160,17 +160,6 @@
*
*/
/* offset of a structure member (used to gen offsets for ihash stuff) */
#if _MSC_VER
/* Microsoft compile complains about size of (void*), so must use (char*) */
/* Could use (char*) in UNIX version too. */
#define OFFSET(structure,member) \
( ((char *) &(((structure *) 0))->member) - ((char *) 0) )
#else
#define OFFSET(structure,member) \
( ((void *) &(((structure *) 0))->member) - ((void *) 0) )
#endif
/* data-structures opaque to clients */
#include "bplane/bpOpaque.h"