forked from bartvdbraak/blender
Cleanup: avoid member access within null pointer
While harmless, UBSan warns about this. Prefer offsetof where possible since it's more readable.
This commit is contained in:
parent
c1ae12bf5e
commit
99fb853734
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h> /* offsetof */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h> /* memcpy */
|
#include <string.h> /* memcpy */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -153,7 +154,7 @@ static const char *check_memlist(MemHead *memh);
|
|||||||
#define MEMTAG3 MAKE_ID('O', 'C', 'K', '!')
|
#define MEMTAG3 MAKE_ID('O', 'C', 'K', '!')
|
||||||
#define MEMFREE MAKE_ID('F', 'R', 'E', 'E')
|
#define MEMFREE MAKE_ID('F', 'R', 'E', 'E')
|
||||||
|
|
||||||
#define MEMNEXT(x) ((MemHead *)(((char *)x) - ((char *)&(((MemHead *)0)->next))))
|
#define MEMNEXT(x) ((MemHead *)(((char *)x) - offsetof(MemHead, next)))
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* vars */
|
/* vars */
|
||||||
|
Loading…
Reference in New Issue
Block a user