mirror of https://github.com/xzeldon/htop.git
Test realloc failure to make cppcheck happy
This commit is contained in:
parent
99bc23771f
commit
2f0a4b3d3a
13
String.c
13
String.c
|
@ -68,7 +68,13 @@ char** String_split(const char* s, char sep, int* n) {
|
||||||
ctr++;
|
ctr++;
|
||||||
if (ctr == blocks) {
|
if (ctr == blocks) {
|
||||||
blocks += rate;
|
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;
|
s += size + 1;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +85,10 @@ char** String_split(const char* s, char sep, int* n) {
|
||||||
out[ctr] = token;
|
out[ctr] = token;
|
||||||
ctr++;
|
ctr++;
|
||||||
}
|
}
|
||||||
out = realloc(out, sizeof(char*) * (ctr + 1));
|
char** newOut = realloc(out, sizeof(char*) * (ctr + 1));
|
||||||
|
if (newOut) {
|
||||||
|
out = newOut;
|
||||||
|
}
|
||||||
out[ctr] = NULL;
|
out[ctr] = NULL;
|
||||||
*n = ctr;
|
*n = ctr;
|
||||||
return out;
|
return out;
|
||||||
|
|
Loading…
Reference in New Issue