summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-23 16:05:38 -1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-23 19:33:39 -0800
commita9786564c23fbf032f47096f543699c8c402785b (patch)
tree551231e54e017c9e83fd44da59edbe4c94dfa716 /dive.h
parent10ce60e2120419282ff7694e8deda60e94832aa1 (diff)
downloadsubsurface-a9786564c23fbf032f47096f543699c8c402785b.tar.gz
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>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/dive.h b/dive.h
index d4e2d3eaf..adf266b45 100644
--- a/dive.h
+++ b/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);