AllocMemFromVirtualFile -- initialize memory block from virtual file (V6.1)
[id] = AllocMemFromVirtualFile(id, vf$)
This command can be used to access the raw memory contents of a virtual string file created using DefineVirtualFileFromString(). The new memory block object will be made available under the handle id, or, if you specify Nil as id, AllocMemFromVirtualFile() automatically chooses a vacant 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.

identifier for the memory block or Nil for auto id selection
virtual string file allocated by DefineVirtualFileFromString()
optional: identifier of the memory block; will only be returned when you pass Nil as argument 1 (see above)

Show TOC