c11 safe string handling support
[vpp.git] / src / tools / g2 / view1.c
index c524c81..9c86fcd 100644 (file)
@@ -998,7 +998,7 @@ static void move_current_track(GdkEventButton *event,
  found:
     pid_index = i + vp->first_pid_index;
 
-    new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids);
+    new_pidvec = g_malloc0(sizeof(pid_sort_t)*g_npids);
     pold = g_pids;
     pnew = new_pidvec;
 
@@ -1636,7 +1636,7 @@ static void init_track_colors(void)
     if (s_color != NULL ) {
         gdk_colormap_free_colors(gtk_widget_get_colormap(da), 
                                  s_color, g_npids);
-        memset(s_color, 0, sizeof(GdkColor) * g_npids);
+        clib_memset(s_color, 0, sizeof(GdkColor) * g_npids);
     } else {
         /*
          * First time through: allocate the array to hold the GCs.
@@ -1743,7 +1743,7 @@ static void chase_event_etc(enum chase_mode mode)
     datum_to_chase = ep->datum;
     pid_to_chase = ep->pid->pid_value;
     pids_mapped = 0;
-    new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids);
+    new_pidvec = g_malloc0(sizeof(pid_sort_t)*g_npids);
 
     while (1) {
         if (srch_chase_dir == SRCH_CHASE_FORWARD) {
@@ -2128,6 +2128,10 @@ static void view1_button_click_callback(GtkButton *item, gpointer data)
             g_events[g_nevents-1].time * 9) {
             s_v1->minvistime = 0;
             s_v1->maxvistime = g_events[g_nevents-1].time * 9 / 8;
+            /* Single event? Make window 1s wide... */
+            if (g_nevents == 1)
+                s_v1->maxvistime = 1000000;                
+
         }
         recompute_hscrollbar();
         break;
@@ -2967,6 +2971,9 @@ void view1_read_events_callback(void)
     
     s_v1->minvistime = 0LL;
     s_v1->maxvistime = (g_events[g_nevents - 1].time * 9)/ 8;
+    /* Single event? Make the initial display 1s wide */
+    if (g_nevents == 1)
+        s_v1->maxvistime = 1000000;
     s_srchindex = 0;
     s_srchcode = 0;
     s_last_selected_event = 0;