const size_t len = buf.length();
if ( outsize > len )
{
- memcpy(out, buf, (len+1) * sizeof(char));
+ memcpy(out, buf, len+1);
}
else // not enough space
{
- memcpy(out, buf, (outsize-1) * sizeof(char));
+ memcpy(out, buf, outsize-1);
out[outsize-1] = '\0';
}