* avoid wrong warning about FillChar not initializing the output parameter in case count <= 0

This commit is contained in:
florian 2024-01-15 21:54:11 +01:00
parent 4c330f2799
commit 9bb6a32c62

View File

@ -39,8 +39,11 @@ procedure memset(var x; value: byte; count: size_t); cdecl; external clib;
Procedure FillChar(var x;count: sizeint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
begin
if count <= 0 then
exit;
{ don't exit if count is <= 0, this makes the compiler think x is uninitialized,
as FillChar is probably rarely called with count <= 0, the performance hit is
probably neglible }
if count < 0 then
count := 0;
memset(x,value,size_t(count));
end;
{$endif FPC_SYSTEM_HAS_FILLCHAR}