3 ms·
1. Not using container_of/struct_of, but rather peppering code with "(void* )l-sizeof(size_t)" 2. my_list_type.my_array is not properly aligned 3. list_append
by abcd_f 11y ago
1. Not using container_of/struct_of, but rather peppering code with "(void* )l-sizeof(size_t)"
2. my_list_type.my_array is not properly aligned
3. list_append() doesn't handle realloc() failures
4. Doesn't properly () macro argument and lots of macros also reuse their arguments. That sure is going to be fun to debug, e.g. list_len(l++);
In short, if this works for the author - great, but the re-usability of this code is next to zero. The beauty of C is that it's very explicit and verbose. Once you start concealing things behind abstract APIs, you start trading verbosity for implicit invariants leading to obscure bugs and intense head scratching. Not a worthy trade off in hell of a lot of cases.