diff --git a/src/obidms_taxonomy.c b/src/obidms_taxonomy.c index 1b5b700..7bc18e2 100755 --- a/src/obidms_taxonomy.c +++ b/src/obidms_taxonomy.c @@ -2463,6 +2463,32 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode return -1; } + // Write the rest of the taxa from the current taxa list + while (nT < (tax->taxa)->count) + { + // Add element from taxa list + // Enlarge structure if needed + if (n == buffer_size) + { + buffer_size = buffer_size * 2; + tax->merged_idx = (ecomergedidx_t*) realloc(tax->merged_idx, sizeof(ecomergedidx_t) + sizeof(ecomerged_t) * buffer_size); + if (tax->merged_idx == NULL) + { + obi_set_errno(OBI_MALLOC_ERROR); + obidebug(1, "\nError reallocating memory for a taxonomy structure"); + closedir(tax_dir); + fclose(file); + return -1; + } + } + + (tax->merged_idx)->merged[n].taxid = (tax->taxa)->taxon[nT].taxid; + (tax->merged_idx)->merged[n].idx = nT; + + nT++; + n++; + } + // Store count (tax->merged_idx)->count = n; diff --git a/src/obidms_taxonomy.h b/src/obidms_taxonomy.h index ffdb18d..b6ba4a6 100755 --- a/src/obidms_taxonomy.h +++ b/src/obidms_taxonomy.h @@ -75,7 +75,7 @@ typedef struct { */ int32_t max_taxid; /**< Maximum taxid existing in the taxon index. */ - int32_t buffer_size; /**< Number of taxa. // TODO kept this but not sure of its use + int32_t buffer_size; /**< . // TODO kept this but not sure of its use */ ecotx_t taxon[]; /**< Taxon array. */