24cf4a1294b7e146f488b877eb87b9f2e83eaa9c hiram Wed Feb 28 17:39:28 2024 -0800 moving static loadSizes() function from hg/utils/pslCheck.c to lib/common.c no redmine diff --git src/lib/common.c src/lib/common.c index ac30338..41160e5 100644 --- src/lib/common.c +++ src/lib/common.c @@ -1,27 +1,27 @@ /* Commonly used routines in a wide range of applications. * Strings, singly-linked lists, and a little file i/o. * * This file is copyright 2002 Jim Kent, but license is hereby * granted for all use - public, private or commercial. */ #include "common.h" #include "errAbort.h" #include "portable.h" #include "linefile.h" #include "hash.h" - +#include "sqlNum.h" void *cloneMem(void *pt, size_t size) /* Allocate a new buffer of given size, and copy pt to it. */ { void *newPt = needLargeMem(size); memcpy(newPt, pt, size); return newPt; } static char *cloneStringZExt(const char *s, int size, int copySize) /* Make a zero terminated copy of string in memory */ { char *d = needMem(copySize+1); copySize = min(size,copySize); memcpy(d, s, copySize); @@ -3882,15 +3882,28 @@ if (stringIn("_hap", name) || stringIn("_alt", name)) return TRUE; else return FALSE; } char *shorterDouble(double value) /* Work around a "bug" in %g output that goes into scientific notation too early. */ { static char g15buffer[4096]; sprintf(g15buffer, "%.15g", value); return cloneString(g15buffer); } + +struct hash *loadSizes(char *sizesFile) +/* load a sizes file */ +{ +struct hash *sizes = hashNew(20); +struct lineFile *lf = lineFileOpen(sizesFile, TRUE); +char *cols[2]; + +while (lineFileNextRowTab(lf, cols, ArraySize(cols))) + hashAddInt(sizes, cols[0], sqlUnsigned(cols[1])); +lineFileClose(&lf); +return sizes; +}