#include "hash.h"
/* Debugging flags. */
-#undef GGC_DUMP
+
+/* Zap memory before freeing to catch dangling pointers. */
#define GGC_POISON
+/* Log alloc and release. Don't enable this unless you want a
+ really really lot of data. */
+#undef GGC_DUMP
+
/* Global lists of roots, rtxs, and trees. */
struct ggc_root
{
/* Initialize the global context. */
ggc_push_context ();
+
+#ifdef GGC_DUMP
+ dump = fopen ("zgcdump", "w");
+ setlinebuf (dump);
+#endif
}
/* Start a new GGC context. Memory allocated in previous contexts
void
ggc_push_context PROTO ((void))
{
- struct ggc_status *gs = (struct ggc_status *) xmalloc (sizeof (*gs));
- bzero (gs, sizeof (*gs));
+ struct ggc_status *gs = (struct ggc_status *) xcalloc (1, sizeof (*gs));
gs->next = ggc_chain;
ggc_chain = gs;
}
struct ggc_rtx *n;
int size = sizeof(*n) + (nslots-1) * sizeof(rtunion);
- n = (struct ggc_rtx *) xmalloc (size);
- bzero ((char *) n, size);
+ n = (struct ggc_rtx *) xcalloc (1, size);
n->chain = ggc_chain->rtxs;
ggc_chain->rtxs = n;
struct ggc_rtvec *v;
int size = sizeof (*v) + (nelt - 1) * sizeof (rtx);
- v = (struct ggc_rtvec *) xmalloc (size);
- bzero ((char *) v, size);
+ v = (struct ggc_rtvec *) xcalloc (1, size);
v->chain = ggc_chain->vecs;
ggc_chain->vecs = v;
struct ggc_tree *n;
int size = sizeof(*n) - sizeof(n->tree) + length;
- n = (struct ggc_tree *) xmalloc (size);
- bzero ((char *) n, size);
+ n = (struct ggc_tree *) xcalloc (1, size);
n->chain = ggc_chain->trees;
ggc_chain->trees = n;
}
-/* Freeing a bit of rtl isn't quite as simple as calling free, there are
- a few associated bits that might need freeing as well. */
+/* Freeing a bit of rtl is as simple as calling free. */
static void
ggc_free_rtx (r)
if (!quiet_flag)
{
time = (time + 500) / 1000;
- fprintf (stderr, "%d,%d,%d,%d %d.%03d}", n_rtxs, n_vecs, n_trees,
+ fprintf (stderr, "%dr,%dv,%dt,%ds %d.%03d}", n_rtxs, n_vecs, n_trees,
n_strings, time / 1000, time % 1000);
}
}
ggc_mark_tree_hash_table (*(struct hash_table **) elt);
}
-#ifdef GGC_DUMP
-/* Don't enable this unless you want a really really lot of data. */
-static void __attribute__((constructor))
-init(void)
-{
- dump = fopen ("zgcdump", "w");
- setlinebuf (dump);
-}
-#endif
-
#if 0
/* GDB really should have a memory search function. Since this is just
for initial debugging, I won't even pretend to get the __data_start