aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/smw/smwclose.x
diff options
context:
space:
mode:
Diffstat (limited to 'noao/onedspec/smw/smwclose.x')
-rw-r--r--noao/onedspec/smw/smwclose.x46
1 files changed, 46 insertions, 0 deletions
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.h>
+
+
+# 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