aboutsummaryrefslogtreecommitdiff
path: root/sys/mwcs/mwclose.x
blob: 441a78c2bd7870381c3b6b7f1f6ed2040cfd09d2 (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <syserr.h>
include <error.h>
include "mwcs.h"

# MW_CLOSE -- Close a MWCS descriptor and deallocate all resources used
# by the descriptor.  Any CTRAN descriptors which have been opened on
# the MWCS are automatically closed if not already manually closed by
# the application.

procedure mw_close (mw)

pointer	mw		#U pointer to MWCS descriptor

int	i
pointer	ct

begin
	# Free any still allocated CTRAN descriptors.
	do i = 1, MAX_CTRAN {
	    ct = MI_CTRAN(mw,i)
	    if (ct != NULL)
		iferr (call mw_ctfree (ct))
		    call erract (EA_WARN)
	}

	# Free the string and data buffers.
	if (MI_SBUF(mw) != NULL)
	    call mfree (MI_SBUF(mw), TY_CHAR)
	if (MI_DBUF(mw) != NULL)
	    call mfree (MI_DBUF(mw), TY_DOUBLE)

	# Free the main descriptor.
	call mfree (mw, TY_STRUCT)
end