mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-25 19:26:56 +01:00
Fix compiler warnings
This commit is contained in:
parent
09d6b9f756
commit
a9ab6078c8
@ -270,20 +270,22 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
|||||||
if (len_rep == 0) {
|
if (len_rep == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} // empty rep causes infinite loop during count
|
} // empty rep causes infinite loop during count
|
||||||
if (!with)
|
if (!with) {
|
||||||
with = "";
|
with = (char *) "";
|
||||||
|
}
|
||||||
len_with = strlen(with);
|
len_with = strlen(with);
|
||||||
|
|
||||||
// count the number of replacements needed
|
// count the number of replacements needed
|
||||||
ins = orig;
|
ins = orig;
|
||||||
for (count = 0; tmp = strstr(ins, rep); ++count) {
|
for (count = 0; (tmp = strstr(ins, rep)); ++count) {
|
||||||
ins = tmp + len_rep;
|
ins = tmp + len_rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = result = (char *) malloc(strlen(orig) + (len_with - len_rep) * count + 1);
|
tmp = result = (char *) malloc(strlen(orig) + (len_with - len_rep) * count + 1);
|
||||||
|
|
||||||
if (!result)
|
if (!result) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// first time through the loop, all the variable are set correctly
|
// first time through the loop, all the variable are set correctly
|
||||||
// from here on,
|
// from here on,
|
||||||
|
Loading…
Reference in New Issue
Block a user