Add a LIST_HEADER macro

To save us from specifying the `next' and `prev' pointers all the time.

It's not perfect, just a tiny bit better.
This commit is contained in:
Přemysl Eric Janouch 2014-07-18 19:51:15 +02:00
parent 353230b18b
commit 43d34d2473
3 changed files with 7 additions and 11 deletions

View File

@ -254,7 +254,9 @@ xstrndup (const char *s, size_t n)
// --- Double-linked list helpers ---------------------------------------------- // --- Double-linked list helpers ----------------------------------------------
// The links of the list need to have the members `prev' and `next'. #define LIST_HEADER(type) \
struct type *next; \
struct type *prev;
#define LIST_PREPEND(head, link) \ #define LIST_PREPEND(head, link) \
BLOCK_START \ BLOCK_START \
@ -562,8 +564,7 @@ error_propagate (struct error **destination, struct error *source)
struct str_map_link struct str_map_link
{ {
struct str_map_link *next; ///< The next link in a chain LIST_HEADER (str_map_link)
struct str_map_link *prev; ///< The previous link in a chain
void *data; ///< Payload void *data; ///< Payload
size_t key_length; ///< Length of the key without '\0' size_t key_length; ///< Length of the key without '\0'

View File

@ -215,9 +215,7 @@ enum
struct client struct client
{ {
struct client *next; ///< The next link in a chain LIST_HEADER (client)
struct client *prev; ///< The previous link in a chain
struct server_context *ctx; ///< Server context struct server_context *ctx; ///< Server context
int socket_fd; ///< The TCP socket int socket_fd; ///< The TCP socket
@ -310,8 +308,7 @@ enum
struct channel_user struct channel_user
{ {
struct channel_user *prev; LIST_HEADER (channel_user)
struct channel_user *next;
unsigned modes; unsigned modes;
char nickname[]; char nickname[];

View File

@ -52,9 +52,7 @@ static struct config_item g_config_table[] =
struct plugin_data struct plugin_data
{ {
struct plugin_data *next; ///< The next link in a chain LIST_HEADER (plugin_data)
struct plugin_data *prev; ///< The previous link in a chain
struct bot_context *ctx; ///< Parent context struct bot_context *ctx; ///< Parent context
pid_t pid; ///< PID of the plugin process pid_t pid; ///< PID of the plugin process