The ts_tsdesc structure

A ts_tsdesc structure contains a time series (ts_timeseries) and data structures for working with it. Among other things, ts_tsdesc tracks the current element and holds two element buffers for creating two elements.
Important: The two element buffers are shared by the element-fetching functions. An element that is fetched is overwritten two fetch calls later. Elements fetched by functions like ts_elem() should not be explicitly freed. They are freed when the ts_tsdesc is closed.

If you must look at more than two elements at a time, open a scan or use the ts_make_elem() or ts_make_elem_with_buf() routines to make a copy of one of your elements.

A ts_tsdesc structure is created by the ts_open() function and destroyed by the ts_close() procedure. It is used by most of the time series API routines.