[id] = AllocMemFromVirtualFile(id, vf$)
id
, or, if you specify Nil as id
, AllocMemFromVirtualFile()
automatically chooses an identifier and returns it.
Note that AllocMemFromVirtualFile()
will not make a local copy of the memory
owned by the virtual string file. It will just allocate a container object
so that you can access the memory data using the memory block functions.
Also note that when dealing with writeable virtual string files their memory
representation can change with every single write operation performed on
the virtual string file. Thus, it is not safe to access the virtual string file's
memory through a container obtained from AllocMemFromVirtualFile()
after a
write operation to this virtual string file. Instead, you have to obtain
a new container after every write operation and free the old one using
FreeMem() first. Everything else will crash sooner or
later.
Also note that it is forbidden to write to the memory block allocated by this function unless the virtual string file was created as writable.
Be warned that this is a dangerous function and should only be used by people who know what they are doing. Reading from or writing to non-allocated memory can easily crash your program and cause all sorts of issues.