Prev
Up
Next![]()
|
|
The body of ArrowCreateArray is as follows (setsize is passed to formal parameter n):
static Concept **
ArrowCreateArray (concepts,set,n)
Concept **concepts;
Set *set;
int *n;
{
Concept **tab;
int s,c;
if (0 == set->size) {
return (Concept**) NULL;
}
tab = (Concept**) malloc (sizeof(Concept*) * set->size);
if (!tab) {
panic ("Malloc failed in %s:%i",__FILE__,__LINE__);
}
c = 0;
s = SetFirst (set);
while (-1 != s) {
tab[c++] = concepts[s];
s = SetNext(set,s);
}
*n = c;
return tab;
}
The assignment to
reference parameter n occurs in the one but last line. We
notice that the function may be exited earlier if the precondition
0 == set->size fails. In this case, setsize
remains uninitialized.
![]()