From a9786564c23fbf032f47096f543699c8c402785b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 23 Nov 2012 16:05:38 -1000 Subject: 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 Signed-off-by: Dirk Hohndel --- dive.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'dive.h') 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); -- cgit v1.2.3-70-g09d2