#include <stdio.h>
#include <graphviz/cgraph.h>
-static void prstats(Agraph_t * g, int verbose);
-static void do_it(Agraph_t * g, int dostat);
-
-
static void my_ins(Agraph_t * g, Agobj_t * obj, void *context)
{
Agnode_t *n;
prev = agopen("some_name", Agdirected, NIL(Agdisc_t *));
agcallbacks(prev, FALSE);
agpushdisc(prev, &mydisc, NIL(void *));
- while (g = agconcat(prev, stdin, NIL(Agdisc_t *))) {
- /*do_it(g, dostat); */
- }
/*agwrite(prev,stdout); */
fprintf(stderr, "ready to go, computer fans\n");
agcallbacks(prev, TRUE);
agclose(prev);
return 1;
}
-
-static void prstats(Agraph_t * g, int verbose)
-{
-#ifdef HAVE_VMALLOC
- Vmstat_t ss, *s;
- vmstat(g->cmn->heap, &ss);
- s = &ss;
- if (verbose)
- fprintf(stderr,
- "n_busy %d n_free %d s_busy %d s_free %d m_busy %d m_free %d n_seg %d extent %d\n",
- s->n_busy, s->n_free, s->s_busy, s->s_free, s->m_busy,
- s->m_free, s->n_seg, s->extent);
- else
- fprintf(stderr, "%d (%d,%d)\n", s->extent, s->s_busy, s->s_free);
-#endif
-}
-
-static void do_it(Agraph_t * g, int dostat)
-{
- agwrite(g, stdout);
- if (dostat)
- prstats(g, dostat > 1);
-}
#include <cghdr.h>
/* memory management discipline and entry points */
-
-#if defined(HAVE_VMALLOC)
-
- /* vmalloc based allocator */
-static void *memopen(void)
-{
-#if defined(DEBUG) || defined(MEMDEBUG)
- return vmopen(Vmdcheap, Vmdebug,
- VM_MTDEBUG | VM_DBCHECK | VM_DBABORT | VM_TRACE);
-#else
- return vmopen(Vmdcheap, Vmbest, VM_MTBEST);
-#endif
-}
-
-static void *memalloc(void *heap, size_t request)
-{
- void *rv;
- rv = vmalloc((Vmalloc_t *) heap, request);
- if (rv) memset(rv, 0, request);
- return rv;
-}
-
-static void *memresize(void *heap, void *ptr, size_t oldsize,
- size_t request)
-{
- void *rv;
-
- rv = vmresize((Vmalloc_t *) heap, ptr, request, VM_RSCOPY | VM_RSZERO);
- return rv;
-}
-
-static void memfree(void *heap, void *ptr)
-{
- vmfree((Vmalloc_t *) heap, ptr);
-}
-
-static void memclose(void *heap)
-{
- vmclose((Vmalloc_t *) heap);
-}
-
-Agmemdisc_t AgMemDisc =
- { memopen, memalloc, memresize, memfree, memclose };
-
-#else
-
- /* malloc based allocator */
-
static void *memopen(Agdisc_t* disc)
{
return NIL(void *);
Agmemdisc_t AgMemDisc =
{ memopen, memalloc, memresize, memfree, memclose };
-#endif
-
-
void *agalloc(Agraph_t * g, size_t size)
{
void *mem;