Definition: |
include machine.e (or safe.e)
register_block(atom a, integer i) |
Description: | Add a block of memory to the list of safe blocks maintained by safe.e (the debug version of machine.e ). The block starts at address a. The length of the block is i bytes. |
Comments: | This routine is only meant to be used for
debugging purposes
.
safe.e
tracks the blocks of memory that your program is allowed to
peek(),
poke(),
mem_copy() etc. These are normally
just the blocks that you have allocated using the
allocate() routine, and which
you have not yet freed using
free().
In some cases, you may
acquire additional, external, blocks of memory, perhaps as a result
of calling a C routine. If you are debugging your program using
safe.e
, you must register these external blocks of memory or
safe.e
will prevent you from
accessing them. When you are finished using an external block you can
unregister it using unregister_block().
When you include machine.e , you will get different versions of register_block() and unregister_block() that do nothing. This makes it easy to switch back and forth between debug and non-debug runs of your program. |
Example: |
atom addr addr = c_func(x, {}) register_block(addr, 5) poke(addr, "ABCDE") unregister_block(addr) |
See Also: | unregister_block, safe.e |