Your code is not safe because there is no evidence that valid memory is allocated at
'p[1]'.
'dim as node ptr proot, ptail' does not necessarily always produce 2 contiguous allocations in memory, and even if this were the case, the allocation order (between
'proot' and
'ptail') may depend on the platform.
A solution (among the possible ones) to ensure 2 contiguous allocations in memory:
Code: Select all
type node
as node ptr pnext
end type
type nodeptrs '' to ensure that .proot and .ptail are contiguous in memory
as node ptr proot
as node ptr ptail
end type
dim as nodeptrs pp
pp.proot = new node
pp.ptail = new node
pp.proot->pnext = pp.ptail
dim as node ptr ptr p = @pp.proot '' or p = @pp
?p[0] & " " & p[1]
?pp.proot & " " & pp.ptail
delete pp.proot
delete pp.ptail
sleep