-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_func.c
80 lines (67 loc) · 1.24 KB
/
test_func.c
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
80
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
// extern のテストで使う
int f84_ext1;
int *f84_ext2;
// テストのときに使う関数
int foo_return2() {
return 2;
}
int foo_with_args_add(int a, int b) {
return a + b;
}
int foo_with_args_add6(
int a1,
int a2,
int a3,
int a4,
int a5,
int a6
) {
return a1 + a2 + a3 + a4 + a5 + a6;
}
void dump_address(void *p) {
fprintf(stderr, "p ... %p\n", p);
}
void alloc_3num_ary_8_byte_cell(int **p) {
int *lp = *p = (void *)calloc(4, 8);
lp[0] = 2;
lp[1] = 3;
lp[2] = 4;
lp[3] = 5;
}
// // テストのテスト用main
// int main() {
// long *p;
//
// alloc_3num_ary_8_byte_cell(&p, 12, 13, 14, 15);
// printf("p[0]: %ld\n", p[0]);
// printf("p[1]: %ld\n", p[1]);
// printf("p[2]: %ld\n", p[2]);
//
// printf("sizeof(int): %ld\n", sizeof(int));
// printf("sizeof(long): %ld\n", sizeof(long));
// return 0;
// }
int add_all1(int x, ...) {
va_list ap;
va_start(ap, x);
for (;;) {
int y = va_arg(ap, int);
if (y == 0)
return x;
x += y;
}
}
int add_all2(int x, int y, ...) {
va_list ap;
va_start(ap, y);
x = x + y;
for (;;) {
int y = va_arg(ap, int);
if (y == 0)
return x;
x += y;
}
}