Logo Search packages:      
Sourcecode: ragel version File versions

template<class T, class Resize>
void SVector< T, Resize >::empty (  )  [inline]

Free all memory used by the vector.

The vector is reset to zero elements. Destructors are called on all elements in the vector. The space allocated for the vector is freed.

Definition at line 109 of file svector.h.

References STable< T >::data.

Referenced by SVector< T, Resize >::operator=().

{
      if ( BaseTable::data != 0 ) {
            /* Get the header and drop the refcount on the data. */
            STabHead *head = ((STabHead*) BaseTable::data) - 1;
            head->refCount -= 1;

            /* If the refcount just went down to zero nobody else is referencing
             * the data. */
            if ( head->refCount == 0 ) {
                  /* Call All destructors. */
                  T *pos = BaseTable::data;
                  for ( long i = 0; i < head->tabLen; pos++, i++ )
                        pos->~T();

                  /* Free the data space. */
                  free( head );
            }

            /* Clear the pointer. */
            BaseTable::data = 0;
      }
}


Generated by  Doxygen 1.6.0   Back to index