The way that the ToolTalk service behaves toward information passed into filter functions and callbacks is a special case. Callback and filter routines called by the ToolTalk service are called with two kinds of arguments:
The context arguments are passed from the ToolTalk service to your application. The API objects referenced by pointers are freed by the ToolTalk service as soon as your callback or filter function returns. If you want to keep any of these objects, you must copy the objects before your function returns.
Note - The way that the ToolTalk service behaves toward information passed into filter functions and callbacks is a special case. In all other instances, the ToolTalk service stores the information in the API allocation stack until you free it.
One of the features of the ToolTalk service is callback support for messages, patterns, and filters. Callbacks are routines in your program that ToolTalk calls when a particular message arrives (message callback) or when a message matches a particular pattern you registered (pattern callback).
To tell the ToolTalk service about these callbacks, add the callback to a message or pattern before you send the message or register the pattern.
When you call file query functions such as tt_file_objects_query(), you point to a filter routine that the ToolTalk service calls as it returns items from the query. For example, you could use filter routine used by the ToolTalk file query function to find a specific object. The tt_file_objects_query() function returns all the objects in a file and runs the objects through a filter routine that you provide. Once your filter routine finds the specified object, you can use tt_malloc() to create a storage location and copy the object into the location. When your filter function returns, the ToolTalk service will free all storage used by the objects in the file but the object you stored with the tt_malloc() call will be available for further use.