From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- noao/digiphot/photcal/mctable/mctshrink.x | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 noao/digiphot/photcal/mctable/mctshrink.x (limited to 'noao/digiphot/photcal/mctable/mctshrink.x') diff --git a/noao/digiphot/photcal/mctable/mctshrink.x b/noao/digiphot/photcal/mctable/mctshrink.x new file mode 100644 index 00000000..6a88f230 --- /dev/null +++ b/noao/digiphot/photcal/mctable/mctshrink.x @@ -0,0 +1,31 @@ +include "../lib/mctable.h" + + +# MCT_SHRINK - Free unused table memory + +procedure mct_shrink (table) + +pointer table # table descriptor + +int lsize, psize + +begin + # Check pointer and magic number. + if (table == NULL) + call error (0, "mct_shrink: Null table pointer") + if (MCT_MAGIC (table) != MAGIC) + call error (0, "mct_shrink: Bad magic number") + + # Compute aproximate logical size, and exact physical + # sizes. This might produce a little bit of space wasted. + + lsize = MCT_NPROWS (table) * MCT_MAXCOL (table) + psize = MCT_MAXROW (table) * MCT_MAXCOL (table) + + # Reallocate table sapace and update physical size. + if (lsize != psize) { + call realloc (MCT_DATA (table), lsize, MCT_TYPE (table)) + MCT_MAXROW (table) = MCT_NPROWS (table) + MCT_INCROWS (table) = GROWFACTOR (MCT_MAXROW (table)) + } +end -- cgit