-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplugin.c
More file actions
79 lines (63 loc) · 1.11 KB
/
plugin.c
File metadata and controls
79 lines (63 loc) · 1.11 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <string.h>
int global_int;
typedef struct {
int a;
int b;
} ExampleStruct;
int get_answer() {
return 42;
}
int double_int(int i) {
return i + i;
}
int double_float(float f) {
return f + f;
}
int sum_ints(const int *ints, int size) {
int sum = 0;
for (int i = 0; i < size; i++) {
sum += ints[i];
}
return sum;
}
ExampleStruct get_example_struct() {
return (ExampleStruct) {
.a = 1,
.b = 2,
};
}
ExampleStruct* get_global_example_struct() {
static ExampleStruct g;
return &g;
}
void get_global_example_struct_ptr(ExampleStruct** ptr) {
*ptr = get_global_example_struct();
}
int example_struct_get_a(ExampleStruct s) {
return s.a;
}
int example_struct_pointer_get_a(const ExampleStruct *s) {
return s->a;
}
const char *get_message() {
return "Hello world!";
}
void fill_message(char *msg, int buffer_size) {
strncpy(msg, "Hello world!", buffer_size);
}
int str_length(const char *msg, int max_length) {
if (!msg) {
return 0;
}
int i = 0;
while (*msg && i < max_length) {
i++;
msg++;
}
return i;
}
void call_function_int(void (*f)(int), int value) {
if (f) {
f(value);
}
}