diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-07-13 15:18:52 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-13 15:21:30 -0700 |
commit | e82f8ea565a68aa1fa980cb12c1f136b1d4a57f9 (patch) | |
tree | bf6e7eedb5132ea1920636ed7943be10ce823ecc /taxonomy.c | |
parent | 94d3aa04dccc3c10980188bd357618e2a9f2fa83 (diff) | |
download | subsurface-e82f8ea565a68aa1fa980cb12c1f136b1d4a57f9.tar.gz |
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>
Diffstat (limited to 'taxonomy.c')
-rw-r--r-- | taxonomy.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/taxonomy.c b/taxonomy.c index 40af9fd44..670d85ad0 100644 --- a/taxonomy.c +++ b/taxonomy.c @@ -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; +} |