FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
array_destructobj.c
Go to the documentation of this file.
1
/* ERASE for dynamic arrays of objects: destruct elements and free the array */
2
3
#include "
fb.h
"
4
5
void
fb_hArrayDtorObj
(
FBARRAY
*array,
FB_DEFCTOR
dtor,
size_t
base_idx )
6
{
7
size_t
i, elements, element_len;
8
FBARRAYDIM
*dim;
9
const
char
*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
element_len = array->
element_len
;
23
this_ = (
const
char
*)array->
ptr
+ ((base_idx + (elements-1)) * element_len);
24
25
while
( elements > 0 ) {
26
/* !!!FIXME!!! check exceptions (only if rewritten in C++) */
27
dtor( this_ );
28
this_ -= element_len;
29
--elements;
30
}
31
}
32
33
FBCALL
void
fb_ArrayDestructObj
(
FBARRAY
*array,
FB_DEFCTOR
dtor )
34
{
35
fb_hArrayDtorObj
( array, dtor, 0 );
36
}
rtlib
array_destructobj.c
Generated on Thu Jan 23 2014 19:40:07 for FreeBASIC by
1.8.4