[syslog-ng] need help understanding logqueue-fifo.c code
sasa at balabit.hu
Thu Mar 8 09:58:19 CET 2012
2012. 03. 7, szerda keltezéssel 21.24-kor Evan Rempel ezt írta:
> I am having difficulties understanding the code that handles the LogQueueFifo objects.
> For instance
> static void log_queue_fifo_push_head(LogQueue *s, LogMessage *msg, const LogPathOptions *path_options)
> LogQueueFifo *self = (LogQueueFifo *) s;
> LogMessageQueueNode *node;
The LogQueueFifo structure is defined like this:
typedef struct _LogQueueFifo
/* scalable qoverflow implementation */
struct list_head qoverflow_output;
You could spot that the first member of the LogQueueFifo is LogQueue
type and also important that not a pointer but an embedded field.
With this and knowing the method how the C create this type of embedding
structures you could cast a LogQueueFifo type to LogQueue.
This is some type of poor's man inheritance in C.
Product Security Specialist
e-mail: attila.szalay at balabit.com
phone: +36 1 398 6707
BalaBit IT Security
H-1117 Budapest, Aliz street 2.
This Communication is Confidential. We only send and receive email on
the basis of the term set out at http://www.balabit.com/disclaimer/.
More information about the syslog-ng