--- ray/src/hd/sm_sets.c 1998/09/16 18:16:29 3.3 +++ ray/src/hd/sm_sets.c 2003/02/22 02:07:25 3.6 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: sm_sets.c,v 3.6 2003/02/22 02:07:25 greg Exp $"; #endif - /* * Quadtree-specific set operations. */ @@ -29,26 +26,26 @@ QUADTREE qtnewleaf(oset) /* return new leaf node for object set */ OBJECT *oset; { - register QUADTREE osi; + register QUADTREE osi; - if (*oset <= 0) - return(EMPTY); /* should be error? */ - if (qtfreesets != EMPTY) { - osi = qtfreesets; - qtfreesets = (int)qtsettab[osi]; - } else if ((osi = qtnumsets++) % QTSETIBLK == 0) { - qtsettab = (OBJECT **)realloc((char *)qtsettab, - (unsigned)(osi+QTSETIBLK)*sizeof(OBJECT *)); - if (qtsettab == NULL) - goto memerr; - } - qtsettab[osi] = (OBJECT *)malloc(QTNODESIZ(*oset)*sizeof(OBJECT)); - if (qtsettab[osi] == NULL) - goto memerr; - setcopy(qtsettab[osi], oset); - return(QT_INDEX(osi)); + if (*oset <= 0) + return(EMPTY); /* should be error? */ + if (qtfreesets != EMPTY) { + osi = qtfreesets; + qtfreesets = (int)qtsettab[osi]; + } else if ((osi = qtnumsets++) % QTSETIBLK == 0) { + qtsettab = (OBJECT **)realloc((char *)qtsettab, + (unsigned)(osi+QTSETIBLK)*sizeof(OBJECT *)); + if (qtsettab == NULL) + goto memerr; + } + qtsettab[osi] = (OBJECT *)malloc(QTNODESIZ(*oset)*sizeof(OBJECT)); + if (qtsettab[osi] == NULL) + goto memerr; + setcopy(qtsettab[osi], oset); + return(QT_INDEX(osi)); memerr: - error(SYSTEM, "out of memory in qtnewleaf"); + error(SYSTEM, "out of memory in qtnewleaf"); } @@ -70,7 +67,7 @@ OBJECT id; lf = QT_SET_INDEX(qt); #endif if (qtsettab[lf][0] <= 1) { /* blow leaf away */ - free((char *)qtsettab[lf]); + free((void *)qtsettab[lf]); qtsettab[lf] = (OBJECT *)qtfreesets; qtfreesets = lf; return(EMPTY); @@ -142,7 +139,7 @@ QUADTREE qt; osi = QT_SET_INDEX(qt); if (osi >= qtnumsets) return; - free((char *)qtsettab[osi]); + free((void *)qtsettab[osi]); qtsettab[osi] = (OBJECT *)qtfreesets; qtfreesets = osi; } @@ -159,8 +156,8 @@ qtfreeleaves() /* free ALL sets and leaf nodes */ } for (i = qtnumsets; i--; ) if (qtsettab[i] != NULL) - free((char *)qtsettab[i]); - free((char *)qtsettab); + free((void *)qtsettab[i]); + free((void *)qtsettab); qtsettab = NULL; qtnumsets = 0; } @@ -195,4 +192,12 @@ register OBJECT *cs; /* cs' = cs + for (i = os[0]; i-- >= 0; ) *cs++ = *os++; } + + + + + + + +