mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:24:58 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user