Do not move memory to itself

To move the memory is only needed, when the memory is really freshly
allocated.
This commit is contained in:
Benedikt Heine 2017-12-19 11:46:49 +01:00
parent 1d39aa348c
commit 48ec829c74

View File

@ -29,9 +29,9 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl)
tmp = buf; tmp = buf;
} else { } else {
tmp = g_malloc(size); tmp = g_malloc(size);
memcpy(tmp, buf, pos);
} }
memcpy(tmp, buf, pos);
memcpy(tmp + pos, repl, repl_len); memcpy(tmp + pos, repl, repl_len);
memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1); memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1);