--- ray/src/hd/rholo3.c 1997/11/10 18:06:18 3.6 +++ ray/src/hd/rholo3.c 1997/11/24 15:18:30 3.10 @@ -110,24 +110,29 @@ int nents; lastin = -1; /* flag full sort */ break; } - if (lastin < 0) /* sort updated list */ - sortcomplist(); return; /* no display */ default: error(CONSISTENCY, "bundle_set called with unknown operation"); } - n = 0; /* allocate packet holder */ - for (i = 0; i < nents; i++) - if (clist[i].nr > n) - n = clist[i].nr; + if (outdev == NULL) + return; + n = 8*RPACKSIZ; /* allocate packet holder */ p = (PACKHEAD *)malloc(packsiz(n)); if (p == NULL) goto memerr; /* display what we have */ for (i = 0; i < nents; i++) if ((b = hdgetbeam(hdlist[clist[i].hd], clist[i].bi)) != NULL) { + if (b->nrm > n) { + n = b->nrm; + p = (PACKHEAD *)realloc((char *)p, packsiz(n)); + if (p == NULL) + goto memerr; + } bcopy((char *)hdbray(b), (char *)packra(p), (p->nr=b->nrm)*sizeof(RAYVAL)); + p->hd = clist[i].hd; + p->bi = clist[i].bi; disp_packet(p); } free((char *)p); /* clean up */ @@ -284,12 +289,6 @@ sortcomplist() /* fix our list order */ complist+listpos, complen-listpos); free((char *)list2); } - /* check for all finished */ - if (complist[0].nr <= bnrays(hdlist[complist[0].hd],complist[0].bi)) { - free((char *)complist); - complist = NULL; - complen = 0; - } /* drop satisfied requests */ for (i = complen; i-- && complist[i].nr <= bnrays(hdlist[complist[i].hd],complist[i].bi); ) @@ -329,10 +328,10 @@ register PACKET *p; int ncomp; register int i; - if (complen <= 0) - return(0); if (listpos > lastin) /* time to sort the list */ sortcomplist(); + if (complen <= 0) + return(0); p->hd = complist[listpos].hd; p->bi = complist[listpos].bi; ncomp = bnrays(hdlist[p->hd],p->bi);