Blame


1 2051e653 2021-03-13 op /*
2 2051e653 2021-03-13 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 2051e653 2021-03-13 op *
4 2051e653 2021-03-13 op * Permission to use, copy, modify, and distribute this software for any
5 2051e653 2021-03-13 op * purpose with or without fee is hereby granted, provided that the above
6 2051e653 2021-03-13 op * copyright notice and this permission notice appear in all copies.
7 2051e653 2021-03-13 op *
8 2051e653 2021-03-13 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 2051e653 2021-03-13 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 2051e653 2021-03-13 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 2051e653 2021-03-13 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 2051e653 2021-03-13 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 2051e653 2021-03-13 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 2051e653 2021-03-13 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 2051e653 2021-03-13 op */
16 2051e653 2021-03-13 op
17 2051e653 2021-03-13 op #include "telescope.h"
18 2051e653 2021-03-13 op
19 2051e653 2021-03-13 op #include <stdlib.h>
20 2051e653 2021-03-13 op
21 2051e653 2021-03-13 op void
22 2051e653 2021-03-13 op hist_clear_forward(struct histhead *head, struct hist *h)
23 2051e653 2021-03-13 op {
24 2051e653 2021-03-13 op if (h == NULL)
25 2051e653 2021-03-13 op return;
26 2051e653 2021-03-13 op hist_clear_forward(head, TAILQ_NEXT(h, entries));
27 2051e653 2021-03-13 op TAILQ_REMOVE(&head->head, h, entries);
28 2051e653 2021-03-13 op free(h);
29 2051e653 2021-03-13 op }
30 2051e653 2021-03-13 op
31 2051e653 2021-03-13 op void
32 2051e653 2021-03-13 op hist_push(struct histhead *head, struct hist *h)
33 2051e653 2021-03-13 op {
34 2051e653 2021-03-13 op head->len++;
35 2051e653 2021-03-13 op if (TAILQ_EMPTY(&head->head))
36 2051e653 2021-03-13 op TAILQ_INSERT_HEAD(&head->head, h, entries);
37 2051e653 2021-03-13 op else
38 2051e653 2021-03-13 op TAILQ_INSERT_TAIL(&head->head, h, entries);
39 2051e653 2021-03-13 op }