Peter Berg Larsen pebl@math.ku.dk writes:
This memcpyies one element more than needed.. but seemed much nicer than memcpy( ret, p, (len - 1)*sizeof(WHCAR);
I probably should have subtracted one from len, making it obvious that this is a strdupW, like: ret = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof(WCHAR) ); memcpy( ret, p, len*sizeof(WCHAR) ); ret[len] = 0;
If it's really a strdup it's cleaner to copy one more char and get rid of the ret[len] = 0.