Can some one provide minimal example of TAILQ usage out of linux system library with explanation in c which can be compiled using gcc in Linux?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
The
TAILQ_ENTRY
macro is used to establish the pointers used to insert items into the list. You place it into your structure that you want to list up.The
TAILQ_HEAD
is used to define a structure that will act as the container for your link list elements. You provide it with a structure name, and the name of the type that it will contain.Use
TAILQ_INIT
to initialize an instance of your list container.Use the
TAILQ_INSERT_*
macros to add elements.You can use
TAILQ_FOREACH
andTAILQ_FOREACH_REVERSE
to traverse the list.If you want to iterate over the list while removing all its elements, it is probably easier to use a while loop and use the
TAILQ_EMPTY
andTAILQ_FIRST
macros.The above code was mostly taken verbatim from an example I wrote and tested on IDEONE.