Add EXTEND11().
[deliverable/binutils-gdb.git] / gprof / cg_arcs.c
index 8b6184b6bcc5571b41ea2b02cd0f29fb8448c966..d14238decc330b439ed0db9685379d94e2d13f01 100644 (file)
@@ -26,7 +26,9 @@
 #include "sym_ids.h"
 
 Sym *cycle_header;
-int num_cycles;
+unsigned int num_cycles;
+Arc **arcs;
+unsigned int numarcs;
 
 /*
  * Return TRUE iff PARENT has an arc to covers the address
@@ -65,7 +67,8 @@ void
 DEFUN (arc_add, (parent, child, count),
        Sym * parent AND Sym * child AND int count)
 {
-  Arc *arc;
+  static unsigned int maxarcs = 0;
+  Arc *arc, **newarcs;
 
   DBG (TALLYDEBUG, printf ("[arc_add] %d arcs from %s to %s\n",
                           count, parent->name, child->name));
@@ -81,10 +84,42 @@ DEFUN (arc_add, (parent, child, count),
       return;
     }
   arc = (Arc *) xmalloc (sizeof (*arc));
+  memset (arc, 0, sizeof (*arc));
   arc->parent = parent;
   arc->child = child;
   arc->count = count;
 
+  /* If this isn't an arc for a recursive call to parent, then add it
+     to the array of arcs.  */
+  if (parent != child)
+    {
+      /* If we've exhausted space in our current array, get a new one
+        and copy the contents.   We might want to throttle the doubling
+        factor one day.  */
+      if (numarcs == maxarcs)
+       {
+         /* Determine how much space we want to allocate.  */
+         if (maxarcs == 0)
+           maxarcs = 1;
+         maxarcs *= 2;
+       
+         /* Allocate the new array.  */
+         newarcs = (Arc **)xmalloc(sizeof (Arc *) * maxarcs);
+
+         /* Copy the old array's contents into the new array.  */
+         memcpy (newarcs, arcs, numarcs * sizeof (Arc *));
+
+         /* Free up the old array.  */
+         free (arcs);
+
+         /* And make the new array be the current array.  */
+         arcs = newarcs;
+       }
+
+      /* Place this arc in the arc array.  */
+      arcs[numarcs++] = arc;
+    }
+
   /* prepend this child to the children of this parent: */
   arc->next_child = parent->cg.children;
   parent->cg.children = arc;
@@ -540,10 +575,9 @@ Sym **
 DEFUN_VOID (cg_assemble)
 {
   Sym *parent, **time_sorted_syms, **top_sorted_syms;
-  long index;
+  unsigned int index;
   Arc *arc;
-  extern void find_call PARAMS ((Sym * parent,
-                                bfd_vma p_lowpc, bfd_vma p_highpc));
+
   /*
    * initialize various things:
    *      zero out child times.
This page took 0.026906 seconds and 4 git commands to generate.