1
0
forked from aniani/vim

patch 7.4.2062

Problem:    Using dummy variable to compute struct member offset.
Solution:   Use offsetof().
This commit is contained in:
Bram Moolenaar
2016-07-17 20:37:43 +02:00
parent e87e6dddc2
commit 840268400d
5 changed files with 17 additions and 14 deletions

View File

@@ -353,3 +353,14 @@
# endif
# endif
#endif
/*
* In a hashtab item "hi_key" points to "di_key" in a dictitem.
* This avoids adding a pointer to the hashtab item.
* DI2HIKEY() converts a dictitem pointer to a hashitem key pointer.
* HIKEY2DI() converts a hashitem key pointer to a dictitem pointer.
* HI2DI() converts a hashitem pointer to a dictitem pointer.
*/
# define DI2HIKEY(di) ((di)->di_key)
# define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key)))
# define HI2DI(hi) HIKEY2DI((hi)->hi_key)