int rpos = replacepos - atag->data;
memcpy(newdata, atag->data, rpos);
memcpy(&newdata[rpos], replacement, newlen);
memcpy(&newdata[rpos+newlen], &replacepos[replacelen],
&data[atag->len] - &replacepos[replacelen]);
rfx_free(atag->data);
int rpos = replacepos - atag->data;
memcpy(newdata, atag->data, rpos);
memcpy(&newdata[rpos], replacement, newlen);
memcpy(&newdata[rpos+newlen], &replacepos[replacelen],
&data[atag->len] - &replacepos[replacelen]);
rfx_free(atag->data);