Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace stopMemset() with clearString(). #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions hmm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,13 @@ void viterbi(HMM *hmm_ptr, char *O, char* output_buffer, char* aa_buffer,
(vpath[t]==M1_STATE || vpath[t]==M4_STATE ||
vpath[t]==M1_STATE_1 || vpath[t]==M4_STATE_1)) {

stopMemset(dna, STRINGLEN);
stopMemset(dna1, STRINGLEN);//
stopMemset(dna_f, STRINGLEN);//
stopMemset(dna_f1, STRINGLEN);//
stopMemset(protein, STRINGLEN);
stopMemset(insert, STRINGLEN);//
stopMemset(c_delete, STRINGLEN);//
clearString(dna, STRINGLEN);
clearString(dna1, STRINGLEN);
clearString(dna_f, STRINGLEN);
clearString(dna_f1, STRINGLEN);
clearString(protein, STRINGLEN);
clearString(insert, STRINGLEN);
clearString(c_delete, STRINGLEN);

insert_id = 0;
delete_id = 0;
Expand Down
6 changes: 3 additions & 3 deletions run_hmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ void writeAminoAcids(FILE* aa_outfile_fp, thread_data* td, unsigned int buffer)
}

//!! Why are we clearing dna and output buff?
stopMemset(td->output_buffer[buffer][j], STRINGLEN);
stopMemset(td->aa_buffer[buffer][j], STRINGLEN);
stopMemset(td->dna_buffer[buffer][j], STRINGLEN);
clearString(td->output_buffer[buffer][j], STRINGLEN);
clearString(td->aa_buffer[buffer][j], STRINGLEN);
clearString(td->dna_buffer[buffer][j], STRINGLEN);
}
}

Expand Down
11 changes: 3 additions & 8 deletions util_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,7 @@ void print_usage() {

}

void stopMemset(char* ptr, int length) {
int i;
for(i=0; i<length; i++) {
if(ptr[i] == '\0') {
return;
}
ptr[i] = '\0';
}
void clearString(char* str, int length) {
if (str != NULL && length > 0)
str[0] = '\0';
}
8 changes: 7 additions & 1 deletion util_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ QUEUE* deq(unsigned int which);

void cutnpaste_q(QUEUE** dest, unsigned int which);

void stopMemset(char* ptr, int length);
/*
* Sets the string's first charachter to '\0', so string functions handle it
* like an empty string.
*
* NOTE: if you plan to use functions that use a given length, it's safer to use memset
*/
void clearString(char* str, int length);

#endif