Joy Online Manual
NAME |
objc:offsetPtr - Pointer arithmetic and type casting |
SYNOPSIS |
objc:offsetPtr address offset ?type?
DESCRIPTION |
Returns address + offset * size, where size is the size of type if specified, otherwise the size of address's type. If the optional type parameter is given, the returned pointer points to the specified type, else it has the same type as address. |
EXAMPLE |
Allocates 100 bytes. |
tcl> set p [objc:newPtr {char 100}]
char 100@0x218b78
Adds 100 bytes to $p, returning a pointer to {char 100}. |
tcl> objc:offsetPtr $p 1
char 100@0x218bdc
Also adds 100 bytes to $p, returning a pointer to char. |
tcl> objc:offsetPtr $p 100 char
char@0x218bdc
Type-casts $p to a pointer to int |
tcl> objc:offsetPtr $p 0 int
int@0x218b78
SEE ALSO |
objc:newPtr
objc:peek
objc:poke
KEYWORDS |
pointer, type |
Index |