Abstract out dive/sample allocation a bit

We're going to start to want to allocate dives and samples for the
libdivecomputer import too, so let's clean things up a bit for that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2011-09-12 12:56:34 -07:00
parent d45db9fac7
commit aa416e3c96
3 changed files with 64 additions and 49 deletions

8
dive.h
View file

@ -137,7 +137,7 @@ struct dive {
depth_t visibility;
temperature_t airtemp, watertemp;
cylinder_t cylinder[MAX_CYLINDERS];
int samples;
int samples, alloc_samples;
struct sample sample[];
};
@ -193,6 +193,12 @@ static inline unsigned int dive_size(int samples)
return sizeof(struct dive) + samples*sizeof(struct sample);
}
extern struct dive *alloc_dive(void);
extern void record_dive(struct dive *dive);
extern struct sample *prepare_sample(struct dive **divep);
extern void finish_sample(struct dive *dive, struct sample *sample);
extern struct dive *fixup_dive(struct dive *dive);
extern struct dive *try_to_merge(struct dive *a, struct dive *b);