FFlist: add FF_LIST_GET

this macro can be safer to use than `ffListGet` because it detects wrong type convertion
This commit is contained in:
李通洲
2023-10-27 11:52:14 +08:00
parent 04409f4381
commit df245f32ec
+7
View File
@@ -103,4 +103,11 @@ static inline void ffListClear(FFlist* list)
#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy)))
#define FF_LIST_GET(itemType, listVar, index) \
({ \
assert(sizeof(itemType) == (listVar).elementSize); \
assert((listVar).capacity > (index)); \
(itemType*)(listVar).data + (index); \
})
#endif