X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Ftraceset.c;h=181bdd53430de5739316262bc618ebc1e29a2d40;hb=f2923fb2ab6ecc36c74e7845b7b07fe96d3d6d67;hp=568e67212eb5afb9e54a25a5f2b4169fad66c8f2;hpb=a43d67bae425508678e5ae2ffe5dd1e84286b915;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/traceset.c b/ltt/branches/poly/lttv/lttv/traceset.c index 568e6721..181bdd53 100644 --- a/ltt/branches/poly/lttv/lttv/traceset.c +++ b/ltt/branches/poly/lttv/lttv/traceset.c @@ -16,8 +16,12 @@ * MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include +#include #include /* A trace is a sequence of events gathered in the same tracing session. The @@ -70,7 +74,7 @@ LttvTrace *lttv_trace_new(LttTrace *t) LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) { - int i; + guint i; LttvTraceset *s; LttvTrace * trace; @@ -82,11 +86,8 @@ LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) trace = g_ptr_array_index(s_orig->traces, i); trace->ref_count++; - /*CHECK this used ltt_trace_copy while it may not be needed. Need to - define how traces and tracesets are shared */ - g_ptr_array_add( - s->traces, - g_ptr_array_index(s_orig->traces, i)); + g_ptr_array_add(s->traces, + trace); } s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig->a))); return s; @@ -121,6 +122,14 @@ gint lttv_traceset_save(LttvTraceset *s) void lttv_traceset_destroy(LttvTraceset *s) { + guint i; + + for(i=0;itraces->len;i++) { + LttvTrace *trace = g_ptr_array_index(s->traces, i); + lttv_trace_unref(trace); + if(lttv_trace_get_ref_number(trace) == 0) + lttv_trace_destroy(trace); + } g_ptr_array_free(s->traces, TRUE); g_object_unref(s->a); g_free(s); @@ -197,7 +206,7 @@ guint lttv_trace_ref(LttvTrace * t) guint lttv_trace_unref(LttvTrace * t) { - if(t->ref_count > 0) + if(likely(t->ref_count > 0)) t->ref_count--; return t->ref_count;