Wasteful behavior of fpc_dynarray_setlength(), clears memory just to overwrite it
Original Reporter info from Mantis: chebmaster
-
Reporter name:
Original Reporter info from Mantis: chebmaster
- Reporter name:
Description:
This code that executes when an array with RefCount<>1 is copied on SetLength:
source/rtl/inc/dynarr.inc, line 173:
getmem(newp,size);
fillchar(newp^,size,0); // the ENTIRE block. Must clear 2 chunks at the head and tail instead.
if realp^.high < dims[0] then
movelen := realp^.high+1
else
movelen := dims[0];
move(p^,(pointer(newp)+sizeof(tdynarray))^,elesize*movelen); //has a good chance to fill almost the entire block.
Mantis conversion info:
- Mantis ID: 29250
- Platform: all ?
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 32721 (#a7f1ce2e)
- Monitored by: » Vincent (Vincent Snijders)