diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-06-10 10:55:58 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-06-10 10:55:58 +0000 |
commit | a7e831079363e3bb45f3172f6e59ba48e335682b (patch) | |
tree | ee4324eac9a9d66f189fab60498ec42b8226b7fc /gnu/usr.bin/binutils/gprof/cg_arcs.c | |
parent | 467cb0a471d13c5186a6ee166e60b47c30da64e9 (diff) |
Bring Cygnus versions into the trunk, keeping our local patches
Diffstat (limited to 'gnu/usr.bin/binutils/gprof/cg_arcs.c')
-rw-r--r-- | gnu/usr.bin/binutils/gprof/cg_arcs.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/gnu/usr.bin/binutils/gprof/cg_arcs.c b/gnu/usr.bin/binutils/gprof/cg_arcs.c index 8b6184b6bcc..b63102948b0 100644 --- a/gnu/usr.bin/binutils/gprof/cg_arcs.c +++ b/gnu/usr.bin/binutils/gprof/cg_arcs.c @@ -27,6 +27,8 @@ Sym *cycle_header; int num_cycles; +Arc **arcs; +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 int maxarcs = 0; + Arc *arc, **newarcs; DBG (TALLYDEBUG, printf ("[arc_add] %d arcs from %s to %s\n", count, parent->name, child->name)); @@ -85,6 +88,37 @@ DEFUN (arc_add, (parent, child, count), 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; |