aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/ecidentify/ecinit.x
blob: 8b3b7b62d0a9db6d4d9f8bfafae60e357e5c0fa0 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
include	<gset.h>
include	"ecidentify.h"

# EC_INIT -- Allocate and initialize the identify structure.

procedure ec_init (ec)

pointer	ec			# ID pointer

begin
	call calloc (ec, LEN_EC, TY_STRUCT)

	EC_NALLOC(ec) = 20
	EC_NFEATURES(ec) = 0
	EC_CURRENT(ec) = 0
	EC_NLINES(ec) = 0
	EC_LL(ec) = NULL
	EC_ECF(ec) = NULL
	EC_LABELS(ec) = 1

	call malloc (EC_IMAGE(ec), SZ_FNAME, TY_CHAR)
	call malloc (EC_DATABASE(ec), SZ_FNAME, TY_CHAR)
	call malloc (EC_COORDLIST(ec), SZ_FNAME, TY_CHAR)

	call malloc (EC_APNUM(ec), EC_NALLOC(ec), TY_INT)
	call malloc (EC_LINENUM(ec), EC_NALLOC(ec), TY_INT)
	call malloc (EC_PIX(ec), EC_NALLOC(ec), TY_DOUBLE)
	call malloc (EC_ORD(ec), EC_NALLOC(ec), TY_INT)
	call malloc (EC_FIT(ec), EC_NALLOC(ec), TY_DOUBLE)
	call malloc (EC_USER(ec), EC_NALLOC(ec), TY_DOUBLE)
	call malloc (EC_FWIDTHS(ec), EC_NALLOC(ec), TY_REAL)
	call malloc (EC_FTYPES(ec), EC_NALLOC(ec), TY_INT)
end


# EC_FREE -- Free identify structure.

procedure ec_free (ec)

pointer	ec				# ID pointer
int	i

begin
	if (EC_UN(ec) != NULL)
	    call un_close (EC_UN(ec))
	do i = 1, EC_NLINES(ec)
	    call shdr_close (SH(ec,i))
	call mfree (EC_SHS(ec), TY_POINTER)

	call mfree (EC_IMAGE(ec), TY_CHAR)
	call mfree (EC_DATABASE(ec), TY_CHAR)
	call mfree (EC_COORDLIST(ec), TY_CHAR)

	call mfree (EC_APNUM(ec), TY_INT)
	call mfree (EC_LINENUM(ec), TY_INT)
	call mfree (EC_PIX(ec), TY_DOUBLE)
	call mfree (EC_ORD(ec), TY_INT)
	call mfree (EC_FIT(ec), TY_DOUBLE)
	call mfree (EC_USER(ec), TY_DOUBLE)
	call mfree (EC_FWIDTHS(ec), TY_REAL)
	call mfree (EC_FTYPES(ec), TY_INT)

	call mfree (ec, TY_STRUCT)
end