C: ecotag: fixed 2 memory bugs
This commit is contained in:
@ -232,6 +232,7 @@ int obi_ecotag(const char* dms_name,
|
||||
const int* lca_array;
|
||||
index_t* best_match_array;
|
||||
char* best_match_ids;
|
||||
char* best_match_ids_to_store;
|
||||
int32_t best_match_ids_length;
|
||||
int best_match_count;
|
||||
int buffer_size;
|
||||
@ -393,6 +394,7 @@ int obi_ecotag(const char* dms_name,
|
||||
}
|
||||
|
||||
// Check if the sequence columns share the same indexer (allows for quick checking of sequence equality)
|
||||
// TODO check same dms
|
||||
if (strcmp((query_seq_column->header)->indexer_name, (ref_seq_column->header)->indexer_name) == 0)
|
||||
same_indexer = true;
|
||||
else
|
||||
@ -504,7 +506,7 @@ int obi_ecotag(const char* dms_name,
|
||||
id_len = strlen(id);
|
||||
|
||||
// Grow ids array if needed
|
||||
if ((best_match_ids_length+id_len+1) >= best_match_ids_buffer_size)
|
||||
while ((best_match_ids_length+id_len+1) >= best_match_ids_buffer_size)
|
||||
{
|
||||
best_match_ids_buffer_size = best_match_ids_buffer_size*2;
|
||||
best_match_ids = (char*) realloc(best_match_ids, best_match_ids_buffer_size*sizeof(char));
|
||||
@ -599,13 +601,14 @@ int obi_ecotag(const char* dms_name,
|
||||
lca_name = lca->preferred_name;
|
||||
else
|
||||
lca_name = lca->name;
|
||||
best_match_ids_to_store = best_match_ids;
|
||||
}
|
||||
else
|
||||
{
|
||||
assigned = false;
|
||||
lca_name = OBIStr_NA;
|
||||
lca_taxid = OBIInt_NA;
|
||||
best_match_ids = OBITuple_NA;
|
||||
best_match_ids_to_store = OBITuple_NA;
|
||||
score = OBIFloat_NA;
|
||||
}
|
||||
|
||||
@ -614,7 +617,7 @@ int obi_ecotag(const char* dms_name,
|
||||
assigned_taxid_column, lca_taxid,
|
||||
assigned_name_column, lca_name,
|
||||
assigned_status_column, assigned,
|
||||
best_match_column, best_match_ids, best_match_ids_length,
|
||||
best_match_column, best_match_ids_to_store, best_match_ids_length,
|
||||
score_column, best_score
|
||||
) < 0)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user