X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sam_header.c;h=88b6a1c856bbf4e6b073c7c8d6e394c1a305094e;hb=28391e5898804ce6b805016d8c676fdf61442eb3;hp=a1b518101ad20aefb297c240a68756da8eebc371;hpb=ec8ca3b21511355c3770767be5a7c9b54e218a53;p=samtools.git diff --git a/sam_header.c b/sam_header.c index a1b5181..88b6a1c 100644 --- a/sam_header.c +++ b/sam_header.c @@ -366,6 +366,7 @@ static HeaderLine *sam_header_line_parse(const char *headerLine) while (*to && *to=='\t') to++; if ( to-from != 1 ) { debug("[sam_header_line_parse] multiple tabs on line [%s] (%d)\n", headerLine,(int)(to-from)); + free(hline); return 0; } from = to; @@ -769,4 +770,41 @@ void *sam_header_merge(int n, const void **_dicts) return out_dict; } +char **sam_header2tbl_n(const void *dict, const char type[2], const char *tags[], int *n) +{ + int nout = 0; + char **out = NULL; + + *n = 0; + list_t *l = (list_t *)dict; + if ( !l ) return NULL; + + int i, ntags = 0; + while ( tags[ntags] ) ntags++; + + while (l) + { + HeaderLine *hline = l->data; + if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] ) + { + l = l->next; + continue; + } + out = (char**) realloc(out, sizeof(char*)*(nout+1)*ntags); + for (i=0; ivalue; + } + nout++; + l = l->next; + } + *n = nout; + return out; +}