From 6fd96dfe209f45c21b91defb30a9938a49f09b78 Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 13 Aug 2005 16:45:39 +0000 Subject: [PATCH] fix git-svn-id: http://ltt.polymtl.ca/svn@1010 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt-newlib/event.c | 19 ++++++++++++++++--- ltt/branches/poly/ltt-newlib/event.h | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/ltt-newlib/event.c b/ltt/branches/poly/ltt-newlib/event.c index 2cc3c15d..fe299b5d 100644 --- a/ltt/branches/poly/ltt-newlib/event.c +++ b/ltt/branches/poly/ltt-newlib/event.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -411,6 +412,8 @@ guint64 ltt_event_field_element_number(LttEvent *e, LttField *f) * ltt_event_field_element_select * : Set the currently selected element for a sequence or * array field + * O(1) if fields are of fixed size, else O(n) if fields are + * of variable size. *Input params * e : an instance of an event type * f : a field of the instance @@ -422,12 +425,14 @@ void ltt_event_field_element_select(LttEvent *e, LttField *f, unsigned i) LttField *field; unsigned int k; size_t size; + LttEventType *event_type; if(f->field_type->type_class != LTT_ARRAY && f->field_type->type_class != LTT_SEQUENCE) return ; element_number = ltt_event_field_element_number(e,f); + event_type = ltt_event_eventtype(e); /* Sanity check for i : 0..n-1 only, and must be lower or equal element_number */ if(i >= element_number) return; @@ -438,10 +443,18 @@ void ltt_event_field_element_select(LttEvent *e, LttField *f, unsigned i) size = f->sequ_number_size; else size = 0; + + if(field->fixed_size == FIELD_FIXED) { + size += field->field_size * i; + + get_field_type_size(e->tracefile, event_type, + f->offset_root+size, size, field, e->data); - for(k=0;k<=i;k++){ - size += get_field_type_size(e->tracefile, event_type, - f->offset_root+size, size, field, e->data); + } else { + for(k=0;k<=i;k++){ + size += get_field_type_size(e->tracefile, event_type, + f->offset_root+size, size, field, e->data); + } } f->current_element = i; } diff --git a/ltt/branches/poly/ltt-newlib/event.h b/ltt/branches/poly/ltt-newlib/event.h index 3f1f8972..fc50fee9 100644 --- a/ltt/branches/poly/ltt-newlib/event.h +++ b/ltt/branches/poly/ltt-newlib/event.h @@ -19,6 +19,7 @@ #ifndef EVENT_H #define EVENT_H +#include #include LttEvent *ltt_event_new(); @@ -96,7 +97,7 @@ void *ltt_event_data(LttEvent *e); instance. This function returns the number of elements for an array or sequence field in an event. */ -unsigned ltt_event_field_element_number(LttEvent *e, LttField *f); +guint64 ltt_event_field_element_number(LttEvent *e, LttField *f); /* Set the currently selected element for a sequence or array field. */ -- 2.34.1