GEOS SDK TechDocs
|
|
3.4 Creating and Freeing Blocks
|
3.6 Accessing and Altering VM Blocks
VMAttach(), VMDetach()
When you use
VMAlloc()
, the VM manager allocates a global memory block and attaches it to a VM block. However, sometimes you want to allocate the block yourself, or you may have an existing memory block which you want to copy into the VM file.
To do this, you call the routine
VMAttach()
.
VMAttach()
takes three arguments:
VMAttach()
attaches the global memory block to the VM block. The VM Manager becomes the owner of the memory block. The next time the file is updated, the memory block will be copied to the file.
VMAttach()
returns the handle of the VM block. If it could not perform the attach, it returns a null handle and leaves the global memory block unchanged.
You can also detach the global memory block from a VM block. The routine
VMDetach()
disassociates a global memory block from its VM block. The routine takes three arguments: the VM file handle; the VM block handle; and the
GeodeHandle
of the geode which will be made the owner of the memory block. (Passing a null
GeodeHandle
will make the calling geode the block's owner.) The VM manager disassociates the memory block from the VM block, changes the memory block's owner, marks it "non-discardable," and returns its handle. If the VM block is not currently in memory,
VMDetach()
will automatically allocate a memory block, copy the VM block's data into it, and return the memory block's handle. If the VM block was dirty, the block will be updated to the file before it is detached. The next time the VM block is locked, a new global memory block will be allocated for it.
GEOS SDK TechDocs
|
|
3.4 Creating and Freeing Blocks
|
3.6 Accessing and Altering VM Blocks