A common idiom in some code is to do the following:
memset(dest, 0, dest_size); memcpy(dest, src, src_size);
This patch implements a rewrite to avoid storing to the same location twice. The above code is rewritten as:
memcpy(dest, src, dest_size);
memset((char *)dest + dest_size, setVal,
src_size > dest_size ? src_size - dest_size : 0);
This should copy SrcSize bytes, not DestSize, right?