116 |
|
default: |
117 |
|
error(CONSISTENCY, "bundle_set called with unknown operation"); |
118 |
|
} |
119 |
< |
n = 0; /* allocate packet holder */ |
119 |
> |
n = RPACKSIZ; /* allocate packet holder */ |
120 |
|
for (i = 0; i < nents; i++) |
121 |
|
if (clist[i].nr > n) |
122 |
|
n = clist[i].nr; |
126 |
|
/* display what we have */ |
127 |
|
for (i = 0; i < nents; i++) |
128 |
|
if ((b = hdgetbeam(hdlist[clist[i].hd], clist[i].bi)) != NULL) { |
129 |
< |
bcopy((char *)hdbray(b), (char *)packrays(p), |
129 |
> |
if (b->nrm > n) { |
130 |
> |
n = b->nrm; |
131 |
> |
p = (PACKHEAD *)realloc((char *)p, packsiz(n)); |
132 |
> |
if (p == NULL) |
133 |
> |
goto memerr; |
134 |
> |
} |
135 |
> |
bcopy((char *)hdbray(b), (char *)packra(p), |
136 |
|
(p->nr=b->nrm)*sizeof(RAYVAL)); |
137 |
+ |
p->hd = clist[i].hd; |
138 |
+ |
p->bi = clist[i].bi; |
139 |
|
disp_packet(p); |
140 |
|
} |
141 |
|
free((char *)p); /* clean up */ |
280 |
|
done_packets(flush_queue()); |
281 |
|
if (complen <= 0) /* check to see if there is even a list */ |
282 |
|
return; |
283 |
< |
if (lastin < 0) /* flag to sort entire list */ |
283 |
> |
if (lastin < 0 || listpos*4 >= complen*3) |
284 |
|
qsort((char *)complist, complen, sizeof(PACKHEAD), beamcmp); |
285 |
|
else if (listpos) { /* else sort and merge sublist */ |
286 |
|
list2 = (PACKHEAD *)malloc(listpos*sizeof(PACKHEAD)); |