mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Geo taxonomy: correctly store / update the categories
Don't throw away data unless new data has been received. And don't store multiple copies of the same category. And most importantly, never write past the end of the array. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
94d3aa04dc
commit
e82f8ea565
3 changed files with 37 additions and 13 deletions
|
|
@ -38,3 +38,11 @@ void free_taxonomy(struct taxonomy_data *t)
|
|||
t->nr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int taxonomy_index_for_category(struct taxonomy_data *t, enum taxonomy_category cat)
|
||||
{
|
||||
for (int i = 0; i < t->nr; i++)
|
||||
if (t->category[i].category == cat)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue