mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allocate dive samples separately from 'struct dive'
We used to avoid some extra allocations by just allocating the dive samples as part of the 'struct dive' allocation itself, but that ends up complicating things, and will make it impossible to have multiple different sets of samples (for multiple dive computers). So stop doing it. Just allocate the dive samples array separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
10ce60e212
commit
a9786564c2
7 changed files with 45 additions and 66 deletions
9
dive.h
9
dive.h
|
@ -281,7 +281,7 @@ struct dive {
|
|||
int sac, otu;
|
||||
struct event *events;
|
||||
int samples, alloc_samples;
|
||||
struct sample sample[];
|
||||
struct sample *sample;
|
||||
};
|
||||
|
||||
/* Pa = N/m^2 - so we determine the weight (in N) of the mass of 10m
|
||||
|
@ -415,11 +415,6 @@ extern void show_yearly_stats(void);
|
|||
extern void update_dive(struct dive *new_dive);
|
||||
extern void save_dives(const char *filename);
|
||||
|
||||
static inline unsigned int dive_size(int samples)
|
||||
{
|
||||
return sizeof(struct dive) + samples*sizeof(struct sample);
|
||||
}
|
||||
|
||||
extern timestamp_t utc_mktime(struct tm *tm);
|
||||
extern void utc_mkdate(timestamp_t, struct tm *tm);
|
||||
|
||||
|
@ -427,7 +422,7 @@ extern struct dive *alloc_dive(void);
|
|||
extern void record_dive(struct dive *dive);
|
||||
extern void delete_dive(struct dive *dive);
|
||||
|
||||
extern struct sample *prepare_sample(struct dive **divep);
|
||||
extern struct sample *prepare_sample(struct dive *dive);
|
||||
extern void finish_sample(struct dive *dive);
|
||||
|
||||
extern void report_dives(gboolean imported, gboolean prefer_imported);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue