From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- noao/onedspec/smw/smwclose.x | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 noao/onedspec/smw/smwclose.x (limited to 'noao/onedspec/smw/smwclose.x') diff --git a/noao/onedspec/smw/smwclose.x b/noao/onedspec/smw/smwclose.x new file mode 100644 index 00000000..339ebd98 --- /dev/null +++ b/noao/onedspec/smw/smwclose.x @@ -0,0 +1,46 @@ +include + + +# SMW_CLOSE -- Close the SMW data structure. +# This includes closing the MWCS pointers. + +procedure smw_close (smw) + +pointer smw # SMW pointer + +int i +pointer apids + +begin + if (smw == NULL) + return + + switch (SMW_FORMAT(smw)) { + case SMW_ND: + call mfree (SMW_APID(smw), TY_CHAR) + call mw_close (SMW_MW(smw,0)) + case SMW_ES: + call mfree (SMW_APS(smw), TY_INT) + call mfree (SMW_BEAMS(smw), TY_INT) + call mfree (SMW_APLOW(smw), TY_REAL) + call mfree (SMW_APHIGH(smw), TY_REAL) + call mfree (SMW_APID(smw), TY_CHAR) + apids = SMW_APIDS(smw) - 1 + do i = 1, SMW_NSPEC(smw) + call mfree (Memi[apids+i], TY_CHAR) + call mfree (SMW_APIDS(smw), TY_POINTER) + call mw_close (SMW_MW(smw,0)) + case SMW_MS: + call mfree (SMW_APS(smw), TY_INT) + call mfree (SMW_BEAMS(smw), TY_INT) + call mfree (SMW_APLOW(smw), TY_REAL) + call mfree (SMW_APHIGH(smw), TY_REAL) + call mfree (SMW_APID(smw), TY_CHAR) + apids = SMW_APIDS(smw) - 1 + do i = 1, SMW_NSPEC(smw) + call mfree (Memi[apids+i], TY_CHAR) + do i = 0, SMW_NMW(smw)-1 + call mw_close (SMW_MW(smw,i)) + } + call mfree (smw, TY_STRUCT) +end -- cgit