/* DEC **CopyDecimalArray(pDst,pSrc,n) * * ARGUMENT * pDst is a ptr to the array of destination DEC pointers. * pSrc is a ptr to the array of source DEC pointers * n is the number of elements in pSrc * * DESCRIPTION * Copies pSrc to pDst. If pDst is null, tries to create a * DEC array, then do the copy. If some of the pSrc structures * are null, the non-null ones are still copied. * * SIDE EFFECTS * None. * * RETURNS * Returns pointer to the new structure if successful, otherwise * returns GM_NULLARR. * * POSSIBLE ERROR CODES * * GM_NULLPOINTER * GM_ARGVAL * * AUTHOR * Andy Anderson 15-JAN-1987 18:45 * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. * * MODIFICATIONS * */ #include #include "gm.h" #include "gmsystem.h" DEC **CopyDecimalArray(pDst,pSrc,n) DEC **pDst; DEC **pSrc; int n; { int i; mbool copyback; /* whether list is copied backwards */ /* source must be supplied !! */ _MacStart(GM_DARCPY); if (!pSrc||!pDst) { _MacErr(GM_NULLPOINTER); _MacRet(GM_NULLARR); } if (n<0) { _MacErr(GM_ARGVAL); _MacRet(GM_NULLARR); } /* if n is 0 there's nothing to do */ if (n==0) _MacRet(pDst); /* allow for overlapping arrays */ copyback = (pDst > pSrc); /* At any rate, copy the structure */ i = copyback ? n-1 : 0; while ((i=0)) { (void) CopyDecimal(pDst[i], pSrc[i]); /* CopyDecimal sets error flag if error occurs */ if (copyback) i--; else i++; } _MacRet(pDst); }