mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 21:29:42 +02:00
* avoid wrong warning about FillChar not initializing the output parameter in case count <= 0
This commit is contained in:
parent
4c330f2799
commit
9bb6a32c62
@ -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}
|
Procedure FillChar(var x;count: sizeint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
if count <= 0 then
|
{ don't exit if count is <= 0, this makes the compiler think x is uninitialized,
|
||||||
exit;
|
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));
|
memset(x,value,size_t(count));
|
||||||
end;
|
end;
|
||||||
{$endif FPC_SYSTEM_HAS_FILLCHAR}
|
{$endif FPC_SYSTEM_HAS_FILLCHAR}
|
||||||
|
Loading…
Reference in New Issue
Block a user