ltt_trace_read with external LttEvent
[lttv.git] / ltt / branches / poly / ltt / event.c
index a7772d5daf40d10eee243350e5935daba6bd4f7b..1c2140ef983c9f45b21f0b44ea44271cf8e3e5b5 100644 (file)
 #include <ltt/event.h>
 #include <ltt/trace.h>
 
+
+LttEvent *ltt_event_new()
+{
+  return g_new(LttEvent, 1);
+}
+
+void ltt_event_destroy(LttEvent *event)
+{
+  g_free(event);
+}
+
+
 /*****************************************************************************
  *Function name
  *    ltt_event_refresh_fields   : refresh fields of an event 
  *Input params
  *    offsetRoot      : offset from the root
- *    offsetParent    : offset from the parrent
+ *    offsetParent    : offset from the parent
  *    fld             : field
  *    evD             : event data
  *Return value
@@ -217,9 +229,17 @@ void ltt_event_position(LttEvent *e, LttEventPosition *ep)
   ep->event_time        = e->event_time;
   ep->event_cycle_count = e->event_cycle_count;
   ep->heart_beat_number = e->tracefile->cur_heart_beat_number;
-  ep->old_position      = FALSE;
+  ep->old_position      = TRUE;
   ep->event_offset      = e->data - e->tracefile->buffer - EVENT_HEADER_SIZE ;
   ep->tf                = e->tracefile;
+
+  /* This is a workaround for fast position seek */
+  ep->last_event_pos = e->last_event_pos;
+  ep->prev_block_end_time = e->prev_block_end_time;
+  ep->prev_event_time = e->prev_event_time;
+  ep->pre_cycle_count = e->pre_cycle_count;
+  ep->count = e->count;
+  /* end of workaround */
 }
 
 LttEventPosition * ltt_event_position_new()
@@ -263,6 +283,7 @@ void ltt_event_position_set(LttEventPosition *ep,
 /*****************************************************************************
  * Function name
  *    ltt_event_position_compare : compare two positions
+ *    A NULL value is infinite.
  * Input params
  *    ep1                    : a pointer to event's position structure
  *    ep2                    : a pointer to event's position structure
@@ -278,6 +299,13 @@ gint ltt_event_position_compare(const LttEventPosition *ep1,
 {
   if(ep1->tf != ep2->tf)
     g_error("ltt_event_position_compare on different tracefiles makes no sense");
+  if(ep1 == NULL && ep2 == NULL)
+      return 0;
+  if(ep1 != NULL && ep2 == NULL)
+      return -1;
+  if(ep1 == NULL && ep2 != NULL)
+      return 1;
+    
   if(ep1->block_num < ep2->block_num)
     return -1;
   if(ep1->block_num > ep2->block_num)
@@ -305,8 +333,15 @@ gint ltt_event_position_compare(const LttEventPosition *ep1,
 gint ltt_event_event_position_compare(const LttEvent *event,
                                       const LttEventPosition *ep)
 {
-  g_assert(event->tracefile == ep->tf);
+  if(event == NULL && ep == NULL)
+      return 0;
+  if(event != NULL && ep == NULL)
+      return -1;
+  if(event == NULL && ep != NULL)
+      return 1;
 
+  g_assert(event->tracefile == ep->tf);
   if(event->which_block < ep->block_num)
     return -1;
   if(event->which_block > ep->block_num)
@@ -330,7 +365,10 @@ gint ltt_event_event_position_compare(const LttEvent *event,
 void ltt_event_position_copy(LttEventPosition *dest,
                              const LttEventPosition *src)
 {
-  *dest = *src;
+  if(src == NULL)
+    dest = NULL;
+  else
+    *dest = *src;
 }
 
 
This page took 0.023746 seconds and 4 git commands to generate.