diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/plio/plalloc.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/plio/plalloc.x')
-rw-r--r-- | sys/plio/plalloc.x | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/plio/plalloc.x b/sys/plio/plalloc.x new file mode 100644 index 00000000..1fecf486 --- /dev/null +++ b/sys/plio/plalloc.x @@ -0,0 +1,39 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <plio.h> + +# PL_ALLOC -- Allocate space in the line list buffer, returning the llbuf +# offset of the allocated area as the function value. If overflow occurs +# the buffer is resized. + +int procedure pl_alloc (pl, nwords) + +pointer pl #I mask descriptor +int nwords #I number of words of storage to allocate + +int newbuf +int len, o_len, inc, op +errchk realloc + +begin + len = PL_LLLEN(pl) # current buffer length + inc = PL_LLINC(pl) # length increment + op = PL_LLOP(pl) # next available location + + newbuf = op + op = newbuf + nwords + + for (o_len = len; op >= len; ) { + inc = min (PL_MAXINC, inc * 2) + len = len + inc + } + + if (len != o_len) + call realloc (PL_LLBP(pl), len, TY_SHORT) + + PL_LLLEN(pl) = len + PL_LLINC(pl) = inc + PL_LLOP(pl) = op + + return (newbuf) +end |