CPointer documentation

# CPointer

CPointer inherits from Object and defines no instance variables. It has no subclasses.

CPointer is a "boxed" 32-bit pointer. Pointers are used extensively in PalmOS as arguments to or return values from SYSTRAP calls. C structures and heap-allocated strings can also be accessed through CPointers.
Class-side methods give ways to allocate dynamic memory from PalmOS. You must be careful to free such memory when you are finished, as Pocket Smalltalk does NOT automatically free such memory!
If you need a small buffer of aligned heap memory you can use the global variable PadBuffer. This is a CPointer to a 100-byte region of dynamic memory allocated on startup.

## Methods defined in CPointer:

### Methods for accessing:

- byteAt: index
- byteAt: index put: value
- dwordAt: index
- dwordAt: index put: value
- offsetBy: bytes
- wordAt: index
- wordAt: index put: value

### Methods for comparing:

- = pointer
- hash

### Methods for converting:

- asInteger
- extractCString
  Assumes the receiver is pointing at a 0-terminated (C style) string. Answer a Smalltalk String object.

### Methods for memory management:

- free
  Don't use this for handles---use #freeHandle instead.
- freeHandle
- handleSize
  Answer the number of bytes allocated to the handle.
- lock
- unlock

### Methods for predicates:

- isNull
  ^self asInteger == 0

### Methods for printing:

- printOn: stream

Pocket Smalltalk Documentation