00dd647be13844229b5bacc1c4dd4ade63484af9 braney Wed Sep 26 15:30:53 2018 -0700 oops... free connections in mathWig diff --git src/hg/lib/mathWig.c src/hg/lib/mathWig.c index 5c0de5f..0d3d73a 100644 --- src/hg/lib/mathWig.c +++ src/hg/lib/mathWig.c @@ -98,60 +98,62 @@ sr = hRangeQuery(conn, table, chrom, winStart, winEnd, NULL, &rowOffset); while ((row = sqlNextRow(sr)) != NULL) { unsigned chromStart = sqlUnsigned(row[rowOffset + 1]); unsigned chromEnd = sqlUnsigned(row[rowOffset + 2]); unsigned start = max(0, chromStart - winStart); unsigned end = min(width, chromEnd - winStart); int ii; for (ii = start; ii < end; ii++) array[ii] = sqlFloat(row[rowOffset + 3]); } +hFreeConn(&conn); } void getWigData(char *db, char *table, char *chrom, unsigned winStart, unsigned winEnd, double *array) /* Query the database to find the regions in the WIB file we need to read to get data for a specified range. Only use the smallest of spans. */ { struct sqlConnection *conn = hAllocConn(db); int rowOffset; struct sqlResult *sr; char **row; struct wiggle *wiggleList = NULL, *wiggle; int minSpan = 1000000000; sr = hRangeQuery(conn, table, chrom, winStart, winEnd, NULL, &rowOffset); while ((row = sqlNextRow(sr)) != NULL) { wiggle = wiggleLoad(row + rowOffset); slAddHead(&wiggleList, wiggle); if (wiggle->span < minSpan) minSpan = wiggle->span; } struct wiggle *nextWiggle; for(wiggle = wiggleList; wiggle; wiggle = nextWiggle) { nextWiggle = wiggle->next; if (wiggle->span == minSpan) getWigDataFromFile(wiggle, array, winStart, winEnd); freez(&wiggle); } +hFreeConn(&conn); } void getBigWigData(char *file, char *chrom, unsigned winStart, unsigned winEnd, double *array) /* Query a bigBed file to find the wiggle values we need for a specified range. */ { struct lm *lm = lmInit(0); static char *fileName = NULL; static struct bbiFile *bwf = NULL; if ((fileName == NULL) || differentString(fileName, file)) { if (bwf != NULL) bbiFileClose(&bwf); fileName = cloneString(file);