[fpc-pascal] Get empty memory quickly or... an empty file

Marco van de Voort marcov at stack.nl
Fri Sep 13 15:38:12 CEST 2013


In our previous episode, Reinier Olislagers said:
> However, I'm sure there must be quicker ways (e.g. less newbie code;
> using OS functions to quickly create empty memor, or alternatively
> create a sparse file and zip the file instead of the stream).

Do not create the data, but generate it in an overriden tstream read() call? 

If you can define a function that can generate "count" bytes of data at
position n (in this case the function is constant), then you don't have to
write it out.

Ken in mind that TStream is an abstraction, not necessarily a block of
(RAM or disk) memory.



More information about the fpc-pascal mailing list