X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=message.c;h=ff0d70c9505e94d16a06a544e1a25a5e12bcf523;hp=eab297803336c257823ebe19b74874db3a187f27;hb=a425aedc1ee2c0bba4ba20904943afb21bd6e2e5;hpb=0a0643e3a561de5f34927ea80c2bd0ce6405fd3c diff --git a/message.c b/message.c index eab2978..ff0d70c 100644 --- a/message.c +++ b/message.c @@ -9,22 +9,19 @@ ** ** \*****************************************************************************/ -#include -#include -#include #include "main.h" MESSAGES -struct message *message_first = NULL; -struct message **messagepointer_end = &message_first; +struct lcr_msg *message_first = NULL; +struct lcr_msg **messagepointer_end = &message_first; /* creates a new message with the given attributes. the message must be filled then. after filling, the message_put must be called */ -struct message *message_create(int id_from, int id_to, int flow, int type) +struct lcr_msg *message_create(int id_from, int id_to, int flow, int type) { - struct message *message; + struct lcr_msg *message; - message = (struct message *)MALLOC(sizeof(struct message)); + message = (struct lcr_msg *)MALLOC(sizeof(struct lcr_msg)); if (!message) FATAL("No memory for message.\n"); mmemuse++; @@ -38,7 +35,7 @@ struct message *message_create(int id_from, int id_to, int flow, int type) } /* attaches a message to the end of the message chain */ -void message_put(struct message *message) +void message_put(struct lcr_msg *message) { if (message->id_to == 0) { @@ -52,14 +49,16 @@ void message_put(struct message *message) *messagepointer_end = message; messagepointer_end = &(message->next); + /* Nullify next pointer if recycled messages */ + *messagepointer_end=NULL; } -struct message *message_forward(int id_from, int id_to, int flow, union parameter *param) +struct lcr_msg *message_forward(int id_from, int id_to, int flow, union parameter *param) { - struct message *message; + struct lcr_msg *message; /* get point to message */ - message = (struct message *)((unsigned long)param - ((unsigned long)(&message->param) - (unsigned long)message)); + message = (struct lcr_msg *)((unsigned long)param - ((unsigned long)(&message->param) - (unsigned long)message)); /* protect, so forwarded messages are not freed after handling */ message->keep = 1; @@ -73,9 +72,9 @@ struct message *message_forward(int id_from, int id_to, int flow, union paramete } /* detaches the first messages from the message chain */ -struct message *message_get(void) +struct lcr_msg *message_get(void) { - struct message *message; + struct lcr_msg *message; if (!message_first) { @@ -97,11 +96,11 @@ struct message *message_get(void) } /* free a message */ -void message_free(struct message *message) +void message_free(struct lcr_msg *message) { if (message->keep) return; - FREE(message, sizeof(struct message)); + FREE(message, sizeof(struct lcr_msg)); mmemuse--; }