Acabo de ver tu video, y el error que te marca es por intentar acceder a una región de memoria inválida, y el error está cuando invocas la función FillByte.
Hice lo siguiente para hacer unas pruebas, y a pesar de compilar, presenta unos errores.
Código:
program Main;
type
TArrayBool = array[0..0] of boolean;
PArrayBool = ^TArrayBool;
var
Lista : PArrayBool;
begin
Getmem(Lista,1 + 10*SizeOf(Boolean));
writeln(Lista^[0]);
FillByte(Lista,1+10*SizeOf(Boolean),0);
writeln(Lista^[1]);
writeln(Lista^[3]);
Lista^[3] := TRUE;
writeln(Lista^[3]);
writeln(Lista^[10]);
writeln(Lista^[11]);
writeln(Lista^[12]);
writeln(Lista^[13]);
FreeMem(Lista,1 + 10*SizeOf(Boolean));
writeln('Test');
end.
Código:
fpc main.pas
Free Pascal Compiler version 3.0.0 [2015/12/05] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling main.pas
main.pas(13,20) Warning: range check error while evaluating constants (1 must be between 0 and 0)
main.pas(14,20) Warning: range check error while evaluating constants (3 must be between 0 and 0)
main.pas(15,12) Warning: range check error while evaluating constants (3 must be between 0 and 0)
main.pas(16,20) Warning: range check error while evaluating constants (3 must be between 0 and 0)
main.pas(17,20) Warning: range check error while evaluating constants (10 must be between 0 and 0)
main.pas(18,20) Warning: range check error while evaluating constants (11 must be between 0 and 0)
main.pas(19,20) Warning: range check error while evaluating constants (12 must be between 0 and 0)
main.pas(20,20) Warning: range check error while evaluating constants (13 must be between 0 and 0)
Linking main
/usr/bin/ld: aviso: link.res contiene secciones de salida. ¿Olvidó -T?
23 lines compiled, 0.4 sec
8 warning(s) issued
Si lo ejecuto, obtengo el mismo error que tu, al invocar la función FillByte
Código:
$ ./main
TRUE
Runtime error 216 at $0000000000400252
$0000000000400252
$000000000040018F
Pero si lo comentamos y compilamos de nuevo, no se observa el error, pero lo que no me cuadra el es hecho que se puede acceder a regiones de memoria que no se encuentran dentro de los límites que se especificaron en GetMem
Código:
$ ./main
TRUE
FALSE
TRUE
TRUE
FALSE
FALSE
FALSE
FALSE
Test
Le hice algunos cambios, también debes notar que hay dos funciones, GetMem y Getmem. GetMem es una función que retorna un puntero hacia el espacio de memoria reservado y lo puedes ver en el siguiente código como Lista := GetMem(....). Y Getmem funciona como el GetMem del Delphi.
También puedes observar que en FillByte cambién FillByte(Lista,1+10*SizeOf(Boolean),0) por FillByte(Lista^,1+10*SizeOf(Boolean),0), es ahí donde te marcaba el error 216.
Código:
program Main;
type
TArrayBool = array[0..0] of boolean;
PArrayBool = ^TArrayBool;
var
Lista : PArrayBool;
begin
//Lista := GetMem(1 + 10*SizeOf(Boolean));
Getmem(Lista,1 + 10*SizeOf(Boolean));
writeln(Lista^[0]);
writeln(Lista^[1]);
writeln(Lista^[2]);
FillByte(Lista^,1+10*SizeOf(Boolean),0);
writeln(Lista^[0]);
writeln(Lista^[1]);
writeln(Lista^[2]);
writeln(Lista^[10]);
writeln(Lista^[11]);
writeln(Lista^[12]);
writeln(Lista^[13]);
FreeMem(Lista,1 + 10*SizeOf(Boolean));
writeln('Test');
end.
Salida
Código:
$ ./main
TRUE
TRUE
TRUE
FALSE
FALSE
FALSE
FALSE
FALSE
FALSE
FALSE
Test
Como vez, puso todo a 0, y para comprobar que sólo se inicializan los valores correspondientes, modifico FillByte de 0 a 1
Código:
program Main;
type
TArrayBool = array[0..0] of boolean;
PArrayBool = ^TArrayBool;
var
Lista : PArrayBool;
begin
//Lista := GetMem(1 + 10*SizeOf(Boolean));
Getmem(Lista,1 + 10*SizeOf(Boolean));
writeln(Lista^[0]);
writeln(Lista^[1]);
writeln(Lista^[2]);
FillByte(Lista^,1+10*SizeOf(Boolean),1);
writeln(Lista^[0]);
writeln(Lista^[1]);
writeln(Lista^[2]);
writeln(Lista^[10]);
writeln(Lista^[11]);
writeln(Lista^[12]);
writeln(Lista^[13]);
FreeMem(Lista,1 + 10*SizeOf(Boolean));
writeln('Test');
end.
Salida
Código:
$ ./main
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
FALSE
FALSE
FALSE
Test