Colin Hercus updated novo2sam.pl to support gapped alignment by
novoalign.
+
+Petr Danecek contributed the header parsing library sam_header.c and
+sam2vcf.pl script and added knet support to the RAZF library.
+
}
static inline void append_text(bam_header_t *header, kstring_t *str)
{
- int x = header->l_text, y = header->l_text + str->l + 2; // 2 = 1 byte dret + 1 byte null
+ size_t x = header->l_text, y = header->l_text + str->l + 2; // 2 = 1 byte dret + 1 byte null
kroundup32(x); kroundup32(y);
- if (x < y) header->text = (char*)realloc(header->text, y);
+ if (x < y)
+ {
+ header->n_text = y;
+ header->text = (char*)realloc(header->text, y);
+ if ( !header->text )
+ {
+ fprintf(stderr,"realloc failed to alloc %ld bytes\n", y);
+ abort();
+ }
+ }
+ // Sanity check
+ if ( header->l_text+str->l+1 >= header->n_text )
+ {
+ fprintf(stderr,"append_text FIXME: %ld>=%ld, x=%ld,y=%ld\n", header->l_text+str->l+1,header->n_text,x,y);
+ abort();
+ }
strncpy(header->text + header->l_text, str->s, str->l+1); // we cannot use strcpy() here.
header->l_text += str->l + 1;
header->text[header->l_text] = 0;
va_end(ap);
}
+static list_t *list_prepend(list_t *root, void *data)
+{
+ list_t *l = malloc(sizeof(list_t));
+ l->next = root;
+ l->data = data;
+ return l;
+}
+
static list_t *list_append(list_t *root, void *data)
{
list_t *l = root;
{
hline = sam_header_line_parse(buf);
if ( hline && sam_header_line_validate(hline) )
- hlines = list_append(hlines, hline);
+ hlines = list_prepend(hlines, hline);
else
{
if (hline) sam_header_line_free(hline);