const void test_large_string_size (void) { ELIM (sizeof large_string == MAX + 1); /* The following expressions are not folded without optimization. */ ELIM ('a' == large_string[0]); ELIM ('\0' == large_string[1233]); ELIM ('b' == large_string[1234]); ELIM ('\0' == large_string[1235]); ELIM ('\0' == large_string[MAX - 1]); }
void test_nulstring (void) { T (a2_implicit, 0); T (a3_implicit, 0); T (a3_nul, 0); T (a5_nul1, 0); T (a7_nul2, 0); T (ax_2_nul, 2); T (ax_3_nul, 3); T (ax_3_des_nul, 3); T (ax_100_3, 3); T (ax_100_3 + 4, 0); ELIM (101 == sizeof ax_100_3); ELIM ('\0' == ax_100_3[100]); /* Verify that all three character arrays have the same length as the string literal they are initialized with. */ T (S, 255); T (c256, 255); T ((const char*)sc256, 255); T ((const char*)uc256, 255); /* Verify that all three character arrays have the same contents as the string literal they are initialized with. */ ELIM (0 == memcmp (c256, S, sizeof c256)); ELIM (0 == memcmp (c256, (const char*)sc256, sizeof c256)); ELIM (0 == memcmp (c256, (const char*)uc256, sizeof c256)); ELIM (0 == strcmp (c256, (const char*)sc256)); ELIM (0 == strcmp (c256, (const char*)uc256)); /* Verify that the char16_t array has the expected contents. */ ELIM (c16_4[0] == 1 && c16_4[1] == 0x7fff && c16_4[2] == 0x8000 && c16_4[3] == 0xffff && c16_4[4] == 0); }
static int buildModel(int nolink, int nolap, int elim, int max_comp, int max_expn) { int first, last; FILE *input; DAZZ_READ *reads; LA *local; Pile *pile; void *tbuffer; int *panels, *plists; Overlap ovl; int64 novl; int a, pos; int omax, n, m; int64 smax, tlen; int btip, etip; int npan, nspl, nlas; reads = MODEL.db1->reads; input = MODEL.input; first = MODEL.first; last = MODEL.last; rewind(input); fread(&novl,sizeof(int64),1,input); fread(&TRACE_SPACING,sizeof(int),1,input); if (TRACE_SPACING <= TRACE_XOVR && TRACE_SPACING != 0) TBYTES = sizeof(uint8); else TBYTES = sizeof(uint16); if (TRACE_SPACING > 0) PANEL_SIZE = ((PANEL_TARGET-1)/TRACE_SPACING+1)*TRACE_SPACING; else PANEL_SIZE = ((PANEL_TARGET-1)/100+1)*100; Read_Overlap(input,&ovl); if (ovl.aread >= first) MODEL.first = first = ovl.aread; else while (ovl.aread < first) { fseek(input,TBYTES*ovl.path.tlen,SEEK_CUR); Read_Overlap(input,&ovl); novl -= 1; } local = (LA *) Malloc(novl*sizeof(LA),"Allocating alignments"); if (local == NULL) return (-1); pile = (Pile *) Malloc(((last-first)+1)*sizeof(Pile),"Allocating piles"); if (pile == NULL) { free(local); return (-1); } pile -= first; npan = nspl = nlas = 0; pos = PILE_SPACING/2; a = first-1; omax = m = n = 0; smax = 0; while (ovl.aread < last) { while (a < ovl.aread) { int j, b, e, p; if (a >= first) { if (reads[a].rlen < PANEL_FUDGE) p = 0; else p = ((reads[a].rlen-PANEL_FUDGE) / PANEL_SIZE); for (j = m; j < n; j++) { b = local[j].abpos / PANEL_SIZE; e = (local[j].aepos-1) / PANEL_SIZE; if (e > p) e = p; nlas += e-b; } nspl += 1; npan += p+1; } a += 1; pile[a].first = n; pile[a].where = pos; pile[a].offset = ftello(input) - OvlIOSize; pile[a].panels = npan; if (n-m > omax) omax = n-m; m = n; pos += reads[a].rlen + PILE_SPACING; } local[n].bread = (ovl.bread << 1); if (COMP(ovl.flags)) local[n].bread |= 0x1; local[n].bbpos = ovl.path.bbpos; local[n].bepos = ovl.path.bepos; local[n].btip = btip = tiplen(ovl.path.abpos,ovl.path.bbpos); local[n].etip = etip = tiplen(reads[ovl.aread].rlen-ovl.path.aepos, MODEL.db2->reads[ovl.bread].rlen-ovl.path.bepos); local[n].abpos = ovl.path.abpos - btip; local[n].aepos = ovl.path.aepos + etip; local[n].toff = ftell(input); if (CHAIN_START(ovl.flags)) local[n].etip |= STRT_FLAG; if (CHAIN_NEXT(ovl.flags)) local[n].etip |= SUCC_FLAG; if (ELIM(ovl.flags)) local[n].etip |= ELIM_BIT; n += 1; tlen = TBYTES*ovl.path.tlen; if (smax < tlen) smax = tlen; fseeko(input,tlen,SEEK_CUR); if (feof(input)) break; if (Read_Overlap(input,&ovl)) break; } { int j, b, e, p; if (a < last-1) { MODEL.last = last = a+1; pile = (Pile *) Realloc(pile+first,((last-first)+1)*sizeof(Pile),"Reallocating piles"); pile -= first; } if (a >= first) { if (reads[a].rlen < PANEL_FUDGE) p = 0; else p = ((reads[a].rlen-PANEL_FUDGE) / PANEL_SIZE); for (j = m; j < n; j++) { b = local[j].abpos / PANEL_SIZE; e = (local[j].aepos-1) / PANEL_SIZE; if (e > p) e = p; nlas += e-b; } nspl += 1; npan += p+1; } pile[last].first = n; pile[last].where = pos; pile[last].offset = ftello(input) - OvlIOSize; pile[last].panels = npan; if (n-m > omax) omax = n-m; pile[last].where -= PILE_SPACING/2; pile[last].offset += OvlIOSize; if (n < novl) local = (LA *) Realloc(local,n*sizeof(LA),"Allocating alignments"); } { LA *temp; nlas = n + nlas; panels = (int *) Malloc((npan+1)*sizeof(int),"Panels"); if (panels == NULL) goto error; plists = (int *) Malloc(nlas*sizeof(int),"Panel Lists"); if (plists == NULL) goto error; temp = (LA *) Realloc(local,(n+1)*sizeof(LA),"Finalizing alignments"); if (temp == NULL) goto error; local = temp; tbuffer = Malloc(smax,"Allocating trace buffer"); if (tbuffer == NULL) goto error; } { int a, k; int *manels; int *count; for (k = 0; k <= npan; k++) panels[k] = 0; manels = panels+1; for (a = first; a < last; a++) { int j, b, e, p; count = manels + pile[a].panels; if (reads[a].rlen < PANEL_FUDGE) p = 0; else p = ((reads[a].rlen-PANEL_FUDGE) / PANEL_SIZE); for (j = pile[a].first; j < pile[a+1].first; j++) { b = local[j].abpos / PANEL_SIZE; e = (local[j].aepos-1) / PANEL_SIZE; if (e > p) e = p; for (k = b; k <= e; k++) count[k] += 1; } } for (k = 2; k <= npan; k++) panels[k] += panels[k-1]; for (a = first; a < last; a++) { int j, b, e, p; count = panels + pile[a].panels; if (reads[a].rlen < PANEL_FUDGE) p = 0; else p = ((reads[a].rlen-PANEL_FUDGE) / PANEL_SIZE); p = ((reads[a].rlen-PANEL_FUDGE) / PANEL_SIZE); for (j = pile[a].first; j < pile[a+1].first; j++) { b = local[j].abpos / PANEL_SIZE; e = (local[j].aepos-1) / PANEL_SIZE; if (e > p) e = p; for (k = b; k <= e; k++) plists[count[k]++] = j; local[j].abpos += local[j].btip; local[j].aepos -= (local[j].etip & DATA_ETIP); } } for (k = npan; k >= 1; k--) panels[k] = panels[k-1]; panels[0] = 0; } MODEL.local = local; MODEL.pile = pile; MODEL.omax = omax; MODEL.tbuf = tbuffer; MODEL.tspace = TRACE_SPACING; MODEL.tbytes = TBYTES; MODEL.panels = panels; MODEL.plists = plists; UNDEFINED = 0; if (reLayoutModel(nolink,nolap,elim,max_comp,max_expn)) { UNDEFINED = 1; goto error; } return (0); error: free(local); free(pile+first); return (1); }