ToolTalk User's Guide

Marking and Releasing Information

The tt_mark() and tt_release() functions are a general mechanism to help you easily manage information storage. The tt_mark() and tt_release() functions are typically used at the beginning and end of a routine where the information returned by the ToolTalk service is no longer necessary once the routine has ended.

Marking Information for Storage

To ask the ToolTalk service to mark the beginning of your storage space, use tt_mark. The ToolTalk service returns a mark, an integer that represents a location on the API stack. All the information that the ToolTalk service subsequently returns to you will be stored in locations that come after the mark.

Releasing Information No Longer Needed

When you no longer need the information contained in your storage space, use tt_release() and specify the mark that signifies the beginning of the information you no longer need.

Example of Marking and Releasing Information

Example 13–1 calls tt_mark() at the beginning of a routine that examines the information in a message. When the information examined in the routine is no longer needed and the message has been destroyed, tt_release() is called with the mark to free storage on the stack.


Example 13–1 Getting a Storage Mark

	/*
	 * Get a storage mark so we can easily free all the data
	 * ToolTalk returns to us.
	 */

	mark = tt_mark();

	if (0==strcmp(“ttsample1_value”, tt_message_op(msg_in))) {
			tt_message_arg_ival(msg_in, 0, &val_in);
			xv_set(gauge, PANEL_VALUE, val_in, NULL);
	}

	tt_message_destroy(msg_in);
	tt_release(mark);
	return;