MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / replace

Function replace

Bcore/src/main/cpp/IO.cpp:12–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10list<IO::RelocateInfo> relocate_rule;
11
12char *replace(const char *str, const char *src, const char *dst) {
13 const char *pos = str;
14 int count = 0;
15 while ((pos = strstr(pos, src))) {
16 count++;
17 pos += strlen(src);
18 }
19
20 size_t result_len = strlen(str) + (strlen(dst) - strlen(src)) * count + 1;
21 char *result = (char *) malloc(result_len);
22 memset(result, 0, strlen(result));
23
24 const char *left = str;
25 const char *right = nullptr;
26
27 while ((right = strstr(left, src))) {
28 strncat(result, left, right - left);
29 strcat(result, dst);
30 right += strlen(src);
31 left = right;
32 }
33 strcat(result, left);
34 return result;
35}
36
37const char *IO::redirectPath(const char *__path) {
38 list<IO::RelocateInfo>::iterator iterator;

Callers 3

redirectPathMethod · 0.85
DotToDescriptorFunction · 0.85
DescriptorToDotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected