Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
2f0a4b3d
Commit
2f0a4b3d
authored
11 years ago
by
Hisham Muhammad
Browse files
Options
Download
Email Patches
Plain Diff
Test realloc failure to make cppcheck happy
parent
99bc2377
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
String.c
+11
-2
String.c
with
11 additions
and
2 deletions
+11
-2
String.c
View file @
2f0a4b3d
...
...
@@ -68,7 +68,13 @@ char** String_split(const char* s, char sep, int* n) {
ctr
++
;
if
(
ctr
==
blocks
)
{
blocks
+=
rate
;
out
=
(
char
**
)
realloc
(
out
,
sizeof
(
char
*
)
*
blocks
);
char
**
newOut
=
(
char
**
)
realloc
(
out
,
sizeof
(
char
*
)
*
blocks
);
if
(
newOut
)
{
out
=
newOut
;
}
else
{
blocks
-=
rate
;
break
;
}
}
s
+=
size
+
1
;
}
...
...
@@ -79,7 +85,10 @@ char** String_split(const char* s, char sep, int* n) {
out
[
ctr
]
=
token
;
ctr
++
;
}
out
=
realloc
(
out
,
sizeof
(
char
*
)
*
(
ctr
+
1
));
char
**
newOut
=
realloc
(
out
,
sizeof
(
char
*
)
*
(
ctr
+
1
));
if
(
newOut
)
{
out
=
newOut
;
}
out
[
ctr
]
=
NULL
;
*
n
=
ctr
;
return
out
;
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help