1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include "mwcs.h"
# MW_CTFREE -- Free a CTRAN (coordinate transformation) descriptor. We keep
# track of all allocated CTRAN descriptors in the parent MWCS descriptor, and
# NULL the saved entry for a descriptor when it is freed, thus guaranteeing
# that a descriptor will be freed only once.
procedure mw_ctfree (ct)
pointer ct #U pointer to CTRAN descriptor
int fn, i, j
pointer mw, fc
include "mwcs.com"
begin
if (ct != NULL) {
mw = CT_MW(ct)
if (mw != NULL)
do i = 1, MAX_CTRAN
if (MI_CTRAN(mw,i) == ct) {
# Free private storage for any input WCS functions.
do j = 1, CT_NCALLI(ct) {
fc = CT_FCI(ct,j)
fn = WF_FN(FC_WF(fc))
if (FN_DESTROY(fn) != NULL)
call zcall1 (FN_DESTROY(fn), fc)
}
# Free private storage for any output WCS functions.
do j = 1, CT_NCALLO(ct) {
fc = CT_FCO(ct,j)
fn = WF_FN(FC_WF(fc))
if (FN_DESTROY(fn) != NULL)
call zcall1 (FN_DESTROY(fn), fc)
}
# Free the main CTRAN descriptor.
call mfree (ct, TY_STRUCT)
MI_CTRAN(mw,i) = NULL
break
}
}
end
|