4 ms·
pretty cool, love anything related to C. might want to add anonymous struct. also put function pointers inside struct for simple object-oriented-programming i
by synergy20 3y ago
pretty cool, love anything related to C.
might want to add anonymous struct.
also put function pointers inside struct for simple object-oriented-programming in C.
flexible array is handy, you do one malloc for all, but pointers inside struct is more 'flexible', for example you can put a 'void *' and cast it to various data types. for flexible array, the data types must be chosen first.
- keyle 3y agoIn passing, there is no version of myself that hasn't shot himself in the foot using `void *` at some point :)
- atahanacar 3y ago>but pointers inside struct is more 'flexible', for example you can put a 'void *' and cast it to various data types. But then the array and other members won't be next to each other in memory.
- synergy20 3y agothe cache subsystem might be smart enough to cache the first line, e.g. the size of the array etc, then pull the rest of array content from heap and cache the array as needed, should be fine to me, yes two cache misses instead of one at the beginning.
- stefncb 3y agoThe CPU cache simply pulls the memory next to what you loaded. It doesn't interpret what it sees.