File: jd_plugin.c

package info (click to toggle)
jitterdebugger 0.3.1%2Bgit20200117.b90ff3a-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 180 kB
  • sloc: ansic: 1,581; python: 77; sh: 44; makefile: 42
file content (66 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: MIT

#include <strings.h>

#include "jitterdebugger.h"

extern struct jd_plugin_desc *__jd_builtin[];

void jd_slist_append(struct jd_slist *jd_slist, void *data)
{
	struct jd_slist *l;

	for (l = jd_slist; l && l->next; l = l->next)
		/* do nothing */ ;

	if (!l)
		err_abort("linked list is inconsistent");

	l->next = malloc(sizeof(struct jd_slist));
	if (!l->next)
		err_abort("allocation for link list failed");
	bzero(l->next, sizeof(*l->next));

	l->next->data = data;
}

void jd_slist_remove(struct jd_slist *jd_slist, void *data)
{
	struct jd_slist *last, *l;

	last = jd_slist;
	l = last->next;
	while (l && l->data != data) {
		last = l;
		l = l->next;
	}

	if (!l) {
		warn_handler("Element not found to remove");
		return;
	}
}

void __jd_plugin_init(void)
{
	int i;

	for (i = 0; __jd_builtin[i]; i++) {
		struct jd_plugin_desc *desc = __jd_builtin[i];

		if (desc->init()) {
			err_abort("plugin initialization failed: %s",
				desc->name);
		}
	}
}

void __jd_plugin_cleanup(void)
{
	int i;

	for (i = 0; __jd_builtin[i]; i++) {
		struct jd_plugin_desc *desc = __jd_builtin[i];
		desc->cleanup();
	}
}