d8a632950a717f3ecaddbfb01c0e0b84f5b6726a
markd
  Tue May 21 11:57:36 2019 -0700
remove static limit on size the number of blocks that can be in a bigPsl.  Test case not checked in, as it is 20mb for one record (fixes #23537)

diff --git src/hg/utils/pslToBigPsl/pslToBigPsl.c src/hg/utils/pslToBigPsl/pslToBigPsl.c
index 96fcd4f..0bd85d0 100644
--- src/hg/utils/pslToBigPsl/pslToBigPsl.c
+++ src/hg/utils/pslToBigPsl/pslToBigPsl.c
@@ -22,41 +22,62 @@
   "  -fa=file.fasta\n"
   "NOTE: to build bigBed:\n"
   "   bedToBigBed -type=bed12+13 -tab -as=bigPsl.as file.bigPslInput chrom.sizes output.bb\n"
   );
 }
 
 boolean snakeMode = FALSE;
 
 /* Command line validation table. */
 static struct optionSpec options[] = {
    {"cds", OPTION_STRING},
    {"fa", OPTION_STRING},
    {NULL, 0},
 };
 
-#define MAX_BLOCKS 10000
-unsigned blockSizes[MAX_BLOCKS];
-unsigned blockStarts[MAX_BLOCKS];
-unsigned oBlockStarts[MAX_BLOCKS];
+static unsigned initNumBlocks = 1000;
+static unsigned currentNumBlocks = 0;
+static unsigned *blockSizes = NULL;
+static unsigned *blockStarts = NULL;
+static unsigned *oBlockStarts = NULL;
+
+static void growBlockSpace(unsigned minBlockCount)
+/* Ensure that there is sufficient space in the block arrays  */
+{
+/* always ask for more then min */
+int size = max(2 * minBlockCount, initNumBlocks);
+if (currentNumBlocks == 0)
+    {
+    AllocArray(blockSizes, size);
+    AllocArray(blockStarts, size);
+    AllocArray(oBlockStarts, size);
+    }
+else
+    {
+    ExpandArray(blockSizes, currentNumBlocks, size);
+    ExpandArray(blockStarts, currentNumBlocks, size);
+    ExpandArray(oBlockStarts, currentNumBlocks, size);
+    }
+currentNumBlocks = size;
+}
 
 void outBigPsl(FILE *fp, struct psl *psl, struct hash *fastaHash, struct hash *cdsHash)
 {
 struct bigPsl bigPsl;
 
-if (psl->blockCount > MAX_BLOCKS)
-    errAbort("psl has more than %d blocks, make MAX_BLOCKS bigger in source", MAX_BLOCKS);
+if (psl->blockCount > currentNumBlocks)
+    growBlockSpace(psl->blockCount);
 
 // make sure blocks are represented on reference's positive strand as required by BED format
 boolean didRc = FALSE;
 if (psl->strand[1] == '-')
     {
     didRc = TRUE;
     pslRc(psl); 
     }
 
 bigPsl.chrom = psl->tName;
 bigPsl.chromSize = psl->tSize;
 bigPsl.match = psl->match;
 bigPsl.misMatch = psl->misMatch;
 bigPsl.repMatch = psl->repMatch;
 bigPsl.nCount = psl->nCount;