Cleaned up all list iterations, added macro named LIST_FOREACH.
Previously you would have to do something like this:
for (type foo = (type) list_get_first(list); foo; foo = (type) list_get_next(list)
{
/* code */
}
Now, you can instead write this as:
LIST_FOREACH(type, foo, list,
{
/* code */
})
Basically, boilerplate stuff including the casting is gone.
This commit is contained in:
@@ -79,16 +79,14 @@ static size_t get_messages(struct chat_history_data* data, size_t num, struct cb
|
||||
skiplines = total - num;
|
||||
|
||||
cbuf_append(outbuf, "\n");
|
||||
message = (char*) list_get_first(messages);
|
||||
while (message)
|
||||
LIST_FOREACH(char*, message, messages,
|
||||
{
|
||||
if (--skiplines < 0)
|
||||
{
|
||||
cbuf_append(outbuf, message);
|
||||
lines++;
|
||||
}
|
||||
message = (char*) list_get_next(messages);
|
||||
}
|
||||
});
|
||||
cbuf_append(outbuf, "\n");
|
||||
return lines;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user