1 /*
2  * Copyright (c) 2018 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "log_list.h"
8 
log_list_init(struct log_list_t * list)9 void log_list_init(struct log_list_t *list)
10 {
11 	list->tail = NULL;
12 	list->head = NULL;
13 }
14 
log_list_add_tail(struct log_list_t * list,struct log_msg * msg)15 void log_list_add_tail(struct log_list_t *list, struct log_msg *msg)
16 {
17 	if (list->head == NULL) {
18 		list->head = msg;
19 	} else {
20 		list->tail->next = msg;
21 	}
22 
23 	list->tail = msg;
24 	msg->next = NULL;
25 }
26 
log_list_head_peek(struct log_list_t * list)27 struct log_msg *log_list_head_peek(struct log_list_t *list)
28 {
29 	return list->head;
30 }
31 
log_list_head_get(struct log_list_t * list)32 struct log_msg *log_list_head_get(struct log_list_t *list)
33 {
34 	struct log_msg *msg = list->head;
35 
36 	if (list->head != NULL) {
37 		list->head = list->head->next;
38 	}
39 
40 	return msg;
41 }
42