92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
}
i += clen;
}
@try {
nstr = [self allocMemoryWithSize: nlen + 1];
} @catch (OFException *e) {
[self freeMemory: ustr];
@throw e;
}
j = 0;
for (i = 0; i < ulen; i++) {
|
|
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
}
i += clen;
}
@try {
nstr = [self allocMemoryWithSize: nlen + 1];
} @catch (id e) {
[self freeMemory: ustr];
@throw e;
}
j = 0;
for (i = 0; i < ulen; i++) {
|
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
if (memcmp(string + i, str_c, str_len))
continue;
@try {
tmp = [self resizeMemory: tmp
toSize: tmp_len + i - last +
repl_len + 1];
} @catch (OFException *e) {
[self freeMemory: tmp];
@throw e;
}
memcpy(tmp + tmp_len, string + last, i - last);
memcpy(tmp + tmp_len + i - last, repl_c, repl_len);
tmp_len += i - last + repl_len;
i += str_len - 1;
last = i + 1;
}
@try {
tmp = [self resizeMemory: tmp
toSize: tmp_len + length - last + 1];
} @catch (OFException *e) {
[self freeMemory: tmp];
@throw e;
}
memcpy(tmp + tmp_len, string + last, length - last);
tmp_len += length - last;
tmp[tmp_len] = 0;
|
|
|
|
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
if (memcmp(string + i, str_c, str_len))
continue;
@try {
tmp = [self resizeMemory: tmp
toSize: tmp_len + i - last +
repl_len + 1];
} @catch (id e) {
[self freeMemory: tmp];
@throw e;
}
memcpy(tmp + tmp_len, string + last, i - last);
memcpy(tmp + tmp_len + i - last, repl_c, repl_len);
tmp_len += i - last + repl_len;
i += str_len - 1;
last = i + 1;
}
@try {
tmp = [self resizeMemory: tmp
toSize: tmp_len + length - last + 1];
} @catch (id e) {
[self freeMemory: tmp];
@throw e;
}
memcpy(tmp + tmp_len, string + last, length - last);
tmp_len += length - last;
tmp[tmp_len] = 0;
|