f970f8e2fd81d08901048b2070054dd71ed7f1f1 angie Tue Apr 9 11:47:57 2013 -0700 Use localmem for annoRow storage, instead of many independent malloc & free calls. refs #6152 diff --git src/hg/lib/annoStreamWig.c src/hg/lib/annoStreamWig.c index f465d4e..19a34d0 100644 --- src/hg/lib/annoStreamWig.c +++ src/hg/lib/annoStreamWig.c @@ -82,56 +82,56 @@ { value = BIN_TO_VALUE(wigBuf[i], wiggle->lowerLimit, wiggle->dataRange); if (annoFilterWigValueFails(self->streamer.filters, value, retRightFail)) value = NAN; else validCount++; } int bpOffset = i * wiggle->span; for (j = 0; j < wiggle->span; j++) vector[bpOffset + j] = value; } if (retValidCount != NULL) *retValidCount = validCount; } -static struct annoRow *aswNextRow(struct annoStreamer *vSelf) +static struct annoRow *aswNextRow(struct annoStreamer *vSelf, struct lm *callerLm) /* Return an annoRow encoding the next chunk of wiggle data, or NULL if there are no more items. */ { struct annoStreamWig *self = (struct annoStreamWig *)vSelf; struct annoRow *rowOut = NULL; boolean done = FALSE; while (!done) { - struct annoRow *wigRow = self->wigStr->nextRow(self->wigStr); + struct annoRow *wigRow = self->wigStr->nextRow(self->wigStr, callerLm); if (wigRow == NULL) return NULL; struct wiggle wiggle; wiggleStaticLoad((char **)wigRow->data, &wiggle); checkWibFile(self, wiggle.file); // translate wigRow + bytes to float vector boolean rightFail = FALSE; int validCount = 0; int bpLen = wiggle.chromEnd - wiggle.chromStart; float vector[bpLen]; getFloatArray(self, &wiggle, &rightFail, &validCount, vector); if (rightFail || validCount > 0) { - rowOut = annoRowWigNew(wigRow->chrom, wigRow->start, wigRow->end, rightFail, vector); + rowOut = annoRowWigNew(wigRow->chrom, wigRow->start, wigRow->end, rightFail, vector, + callerLm); done = TRUE; } - annoRowFree(&wigRow, self->wigStr); } return rowOut; } static void aswClose(struct annoStreamer **pVSelf) /* Free wiggleDataStream and self. */ { if (pVSelf == NULL) return; struct annoStreamWig *self = *(struct annoStreamWig **)pVSelf; carefulClose(&(self->wibF)); freeMem(self->wibFile); annoStreamerFree(pVSelf); }