Subject: | Incorrect use of Win32::API::Struct sizeof |
Within sub MemoryStatus there is the following call:-
$MEMORYSTATUSEX->{dwLength} =
Win32::API::Struct->sizeof($MEMORYSTATUSEX);
The current call is using sizeof as a class method which results in the
following warning when run under perl -w:
Use of uninitialized value $first in concatenation (.) or string at
Perl/site/lib/Win32/API/Struct.pm line 139.
Upon inspection it can be seen that the loop is never processed hence a
real size value is never calculated and 0 value is always returned.
$MEMORYSTATUSEX->{dwLength} =
Win32::API::Struct->sizeof($MEMORYSTATUSEX);
print "dwLength = $MEMORYSTATUSEX->{dwLength}\n";
Gives:-
Use of uninitialized value $first in concatenation (.) or string at
Perl/site/lib/Win32/API/Struct.pm line 139.
dwLength = 0
Changing it to the following fixes this:
$MEMORYSTATUSEX->{dwLength} = $MEMORYSTATUSEX->sizeof();
I'm using Win32::SystemInfo v0.11 with Win32::API v0.59 on Windows 2008
R2 64bit but this will happen on any 64bit int compatible build of perl.