4 ms·
"Why on Earth you'd want to allocate a separate list node for each piece of data when you can embed this node directly into the data" It's a good approach when
by dllthomas 11y ago
"Why on Earth you'd want to allocate a separate list node for each piece of data when you can embed this node directly into the data"
It's a good approach when the items may need to be in several lists at once.
- junke 11y agoYou can certainly put the payload into multiple lists. From http://www.crashcourse.ca/introduction-linux-kernel-programming/intermission-lets-talk-about-linked-lists-and-containerof-free http://www.crashcourse.ca/introduction-linux-kernel-programm...: > More to the point, a payload is welcome to participate on several lists, but only after defining an internal list_head object for each list. In other words, unlike the payloads you're used to that contain only pure data and could (theoretically) be on an infinite number of lists at once, objects on kernel lists can be only on those lists for which they have an internal set of links. It's an interesting way to lock down what lists you're willing to be a member of.
- dllthomas 11y agoSorry, yes, rather the problem comes from a sufficiently dynamic set of list memberships.