-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.c
70 lines (59 loc) · 885 Bytes
/
B.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
#include "B.h"
#include <stdio.h>
#include <stdlib.h>
struct B_impl{
double x;
double y;
};
void B_set_double_double(B *pb, double x, double y){
pb->x=x;
pb->y=y;
}
B *B_new_void()
{
B *ret_p=(B*)malloc(sizeof(B));
if(ret_p){
*ret_p=(B){.x=0, .y=0};
}
return ret_p;
}
B *B_new_Bp(B *pb)
{
B *ret=(B*)malloc(sizeof(B));
if(ret){
*ret=*pb;
}
return ret;
}
B *B_new_double_double(double x, double y)
{
B *ret=(B*)malloc(sizeof(B));
if(ret){
*ret=(B){.x=x, .y=y};
}
return ret;
}
void B_delete(B *pb)
{
free(pb);
}
void B_print(B *pb)
{
printf("(%f, %f)\n",pb->x, pb->y);
}
B *B_new_double(double d)
{
B *ret=(B*)malloc(sizeof(B));
if(ret){
*ret=(B){.x=d, .y=d};
}
return ret;
}
void B_set_double(B *pb, double d)
{
pb->x=pb->y=d;
}
void B_set_Bp(B *pb, B *rhs)
{
*pb=*rhs;
}