delphi - Why do I get an access violation when I call FillChar? -


consider sample code:

var p512sector:pbyte; ..... getmem(p512sector, 262144); fillchar( p512sector,262144 ,0); 

when run program, delphi gives me violation access error. why?

use fillchar(p512sector^, 262144, 0) (note dereferencing ^). otherwise overwriting pointer , stuff behind in memory, not allocated buffer.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -