campo-sirio/gfm/daralloc.c
luca ac8ecb0b9f Patch level :2.0 aga 370
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :sistemate le librerie gfm (allineate a partners version)


git-svn-id: svn://10.65.10.50/trunk@10750 c028cbd2-c16b-5b4b-a496-9718f37d4682
2003-01-17 12:20:25 +00:00

78 lines
1.3 KiB
C
Executable File

/* DEC **AllocateDecimalArray(dst, n);
*
* ARGUMENT
* int n;
* DEC **dst;
*
* DESCRIPTION
* Creates an array of n DEC pointers, each pointing to a DEC structure.
* All of the DEC structures are zeroed with in id of 2. If dst is null,
* both the pointers and the structures are allocated. Otherwise, when dst
* is not null, only the structures are allocated and each pointer points to
* the corresponding DEC structure.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* Returns pointer to the new structure if allocation is successful,
* otherwise returns GM_NULLARR.
*
* POSSIBLE ERROR CODES
*
* GM_NOMEMORY
* GM_ARGVAL (if n == 0)
* GM_NULLPOINTER
*
* AUTHOR
* Jared Levy
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include <malloc.h>
#include "gm.h"
#include "gmsystem.h"
DEC **AllocateDecimalArray(dst, n)
int n;
DEC **dst;
{
DEC *b, *p;
int i;
_MacStart(GM_DARALLOC);
if (n<=0) {
_MacErr(GM_ARGVAL);
_MacRet(GM_NULLARR);
}
if (!dst) {
_MacErr(GM_NULLPOINTER);
_MacRet(GM_NULLARR);
}
b = (DEC *) calloc(n,sizeof(DEC));
/* insufficient room for pointers */
if(!b) {
_MacErr(GM_NOMEMORY);
_MacRet(GM_NULLARR);
}
for (i=0; i<n; i++) {
p = &(b[i]);
dst[i] = p;
_MacDZero(p);
}
_MacRet(dst);
}