Hi All! 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 { LogQueue super; /* 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. -- Attila Szalay Product Security Specialist e-mail: attila.szalay@balabit.com phone: +36 1 398 6707 BalaBit IT Security www.balabit.com 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/.