Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
90b61797
Commit
90b61797
authored
Mar 24, 2016
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use calloc instead of malloc in places where it makes sense.
parent
f2f6e359
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
19 deletions
+7
-19
interface.c
interface.c
+1
-2
neighbour.c
neighbour.c
+1
-6
resend.c
resend.c
+1
-3
route.c
route.c
+2
-4
source.c
source.c
+1
-2
xroute.c
xroute.c
+1
-2
No files found.
interface.c
View file @
90b61797
...
...
@@ -74,11 +74,10 @@ add_interface(char *ifname, struct interface_conf *if_conf)
}
}
ifp
=
malloc
(
sizeof
(
struct
interface
));
ifp
=
calloc
(
1
,
sizeof
(
struct
interface
));
if
(
ifp
==
NULL
)
return
NULL
;
memset
(
ifp
,
0
,
sizeof
(
struct
interface
));
strncpy
(
ifp
->
name
,
ifname
,
IF_NAMESIZE
);
ifp
->
conf
=
if_conf
?
if_conf
:
default_interface_conf
;
ifp
->
bucket_time
=
now
.
tv_sec
;
...
...
neighbour.c
View file @
90b61797
...
...
@@ -84,7 +84,7 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
debugf
(
"Creating neighbour %s on %s.
\n
"
,
format_address
(
address
),
ifp
->
name
);
neigh
=
malloc
(
sizeof
(
struct
neighbour
));
neigh
=
calloc
(
1
,
sizeof
(
struct
neighbour
));
if
(
neigh
==
NULL
)
{
perror
(
"malloc(neighbour)"
);
return
NULL
;
...
...
@@ -92,15 +92,10 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
neigh
->
hello_seqno
=
-
1
;
memcpy
(
neigh
->
address
,
address
,
16
);
neigh
->
reach
=
0
;
neigh
->
txcost
=
INFINITY
;
neigh
->
ihu_time
=
now
;
neigh
->
hello_time
=
zero
;
neigh
->
hello_interval
=
0
;
neigh
->
ihu_interval
=
0
;
neigh
->
hello_send_us
=
0
;
neigh
->
hello_rtt_receive_time
=
zero
;
neigh
->
rtt
=
0
;
neigh
->
rtt_time
=
zero
;
neigh
->
ifp
=
ifp
;
neigh
->
next
=
neighs
;
...
...
resend.c
View file @
90b61797
...
...
@@ -127,7 +127,7 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
if
(
resend
->
ifp
!=
ifp
)
resend
->
ifp
=
NULL
;
}
else
{
resend
=
malloc
(
sizeof
(
struct
resend
));
resend
=
calloc
(
1
,
sizeof
(
struct
resend
));
if
(
resend
==
NULL
)
return
-
1
;
resend
->
kind
=
kind
;
...
...
@@ -140,8 +140,6 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
resend
->
seqno
=
seqno
;
if
(
id
)
memcpy
(
resend
->
id
,
id
,
8
);
else
memset
(
resend
->
id
,
0
,
8
);
resend
->
ifp
=
ifp
;
resend
->
time
=
now
;
resend
->
next
=
to_resend
;
...
...
route.c
View file @
90b61797
...
...
@@ -377,7 +377,7 @@ route_stream(int which)
if
(
!
check_specific_first
())
fprintf
(
stderr
,
"Invariant failed: specific routes first in RIB.
\n
"
);
stream
=
malloc
(
sizeof
(
struct
route_stream
));
stream
=
calloc
(
1
,
sizeof
(
struct
route_stream
));
if
(
stream
==
NULL
)
return
NULL
;
...
...
@@ -939,7 +939,7 @@ update_route(const unsigned char *id,
return
NULL
;
}
route
=
malloc
(
sizeof
(
struct
babel_route
));
route
=
calloc
(
1
,
sizeof
(
struct
babel_route
));
if
(
route
==
NULL
)
{
perror
(
"malloc(route)"
);
return
NULL
;
...
...
@@ -956,8 +956,6 @@ update_route(const unsigned char *id,
route
->
hold_time
=
hold_time
;
route
->
smoothed_metric
=
MAX
(
route_metric
(
route
),
INFINITY
/
2
);
route
->
smoothed_metric_time
=
now
.
tv_sec
;
route
->
installed
=
0
;
memset
(
&
route
->
channels
,
0
,
sizeof
(
route
->
channels
));
if
(
channels_len
>
0
)
memcpy
(
&
route
->
channels
,
channels
,
MIN
(
channels_len
,
DIVERSITY_HOPS
));
...
...
source.c
View file @
90b61797
...
...
@@ -132,7 +132,7 @@ find_source(const unsigned char *id,
if
(
!
create
)
return
NULL
;
src
=
malloc
(
sizeof
(
struct
source
));
src
=
calloc
(
1
,
sizeof
(
struct
source
));
if
(
src
==
NULL
)
{
perror
(
"malloc(source)"
);
return
NULL
;
...
...
@@ -146,7 +146,6 @@ find_source(const unsigned char *id,
src
->
seqno
=
seqno
;
src
->
metric
=
INFINITY
;
src
->
time
=
now
.
tv_sec
;
src
->
route_count
=
0
;
if
(
source_slots
>=
max_source_slots
)
resize_source_table
(
max_source_slots
<
1
?
8
:
2
*
max_source_slots
);
...
...
xroute.c
View file @
90b61797
...
...
@@ -138,11 +138,10 @@ struct
xroute_stream
*
xroute_stream
()
{
struct
xroute_stream
*
stream
=
malloc
(
sizeof
(
struct
xroute_stream
));
struct
xroute_stream
*
stream
=
calloc
(
1
,
sizeof
(
struct
xroute_stream
));
if
(
stream
==
NULL
)
return
NULL
;
stream
->
index
=
0
;
return
stream
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment