FreeBASIC  0.91.0
array_destructstr.c
Go to the documentation of this file.
1 /* ERASE for dynamic arrays of var-len strings */
2 
3 #include "fb.h"
4 
5 void fb_hArrayDtorStr( FBARRAY *array, FB_DEFCTOR dtor, size_t base_idx )
6 {
7  ssize_t i, elements;
8  FBARRAYDIM *dim;
9  FBSTRING *this_;
10 
11  if( array->ptr == NULL )
12  return;
13 
14  dim = &array->dimTB[0];
15  elements = dim->elements - base_idx;
16  ++dim;
17 
18  for( i = 1; i < array->dimensions; i++, dim++ )
19  elements *= dim->elements;
20 
21  /* call dtors in the inverse order */
22  this_ = (FBSTRING *)array->ptr + (base_idx + (elements-1));
23 
24  while( elements > 0 ) {
25  if( this_->data != NULL )
26  fb_StrDelete( this_ );
27  --this_;
28  --elements;
29  }
30 }
31 
33 {
34  fb_hArrayDtorStr( array, NULL, 0 );
35 }