X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=parse-xml.c;h=552786b7aa58e3f780e08ce45bd87e80f1cfbbcf;hb=1cbe2444cc6c0c8da9e730561914986506d83770;hp=e920a11f6f0d798b18900ccb23317c95c8ec5162;hpb=3a7d577ff1109c701656854ceb23ed690c340fbc;p=ext%2Fsubsurface.git diff --git a/parse-xml.c b/parse-xml.c index e920a11..552786b 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -39,6 +39,29 @@ void record_dive(struct dive *dive) dive_table.nr = nr+1; } +/* + * Remove a dive from the dive_table array + */ +void delete_dive(struct dive *dive) +{ + int nr = dive_table.nr, i; + struct dive **dives = dive_table.dives; + + /* + * Stupid. We know the dive table is sorted by date, + * we could do a binary lookup. Sue me. + */ + for (i = 0; i < nr; i++) { + struct dive *d = dives[i]; + if (d != dive) + continue; + memmove(dives+i, dives+i+1, sizeof(struct dive *)*(nr-i-1)); + dives[nr] = NULL; + dive_table.nr = nr-1; + break; + } +} + static void start_match(const char *type, const char *name, char *buffer) { if (verbose > 2)