Skip to content

Commit

Permalink
Fixed uninitialized memory error (making valgrind unhappy) (fixes #87)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarco committed Mar 31, 2024
1 parent 49dc9a3 commit 1d97039
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions alignment/cigar.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,8 @@ void cigar_print(
// Check null
if (cigar_is_null(cigar)) return;
// Generate and print operations
char* const buffer = malloc(2*(cigar->end_offset-cigar->begin_offset)+10);
const int buffer_length = 2*(cigar->end_offset-cigar->begin_offset)+20;
char* const buffer = malloc(buffer_length);
cigar_sprint(buffer,cigar,print_matches);
fprintf(stream,"%s",buffer); // Print
// Free
Expand Down Expand Up @@ -744,7 +745,8 @@ void cigar_print_SAM_CIGAR(
// Check null
if (cigar_is_null(cigar)) return;
// Generate and print operations
char* const buffer = malloc(2*(cigar->end_offset-cigar->begin_offset));
const int buffer_length = 4*(cigar->end_offset-cigar->begin_offset)+20;
char* const buffer = malloc(buffer_length);
cigar_sprint_SAM_CIGAR(buffer,cigar,show_mismatches);
fprintf(stream,"%s",buffer); // Print
// Free
Expand Down
13 changes: 8 additions & 5 deletions wavefront/wavefront_compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ bool wavefront_compute_endsfree_required(
if (alg_form->text_begin_free == 0 &&
alg_form->pattern_begin_free == 0) return false;
if (score % (-penalties->match) != 0) return false;
// TODO: Missing condition (not added for efficiency)
// const int endsfree_k = score/(-penalties->match); // (h/v)-coordinate for boundary conditions
// const bool text_begin_free = (alg_form->text_begin_free >= endsfree_k);
// const bool pattern_begin_free = (alg_form->pattern_begin_free >= endsfree_k);
// if (!text_begin_free && !pattern_begin_free) return false;
// Check boundary conditions for ends-free
const int endsfree_k = score/(-penalties->match); // (h/v)-coordinate for boundary conditions
const bool text_begin_free = (alg_form->text_begin_free >= endsfree_k);
const bool pattern_begin_free = (alg_form->pattern_begin_free >= endsfree_k);
if (!text_begin_free && !pattern_begin_free) return false;
// Ok
return true;
}
Expand Down Expand Up @@ -254,6 +254,9 @@ wavefront_t* wavefront_compute_endsfree_allocate_null(
}
wavefront->lo = lo;
wavefront->hi = hi;
// Set max/min init elements
wavefront->wf_elements_init_min = lo;
wavefront->wf_elements_init_max = hi;
// Return
return wavefront;
}
Expand Down

0 comments on commit 1d97039

Please sign in to comment.