gstring: utilize allocated_len in g_string_replace
If the string has enough space for the original string and the new string, don't allocate a new string. Make space for the new string and move back the original string after the NULL terminator of the old string: "new_string\0original_string\0".