Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
block.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11
12#include <assert.h>
13#include <circogen/circular.h>
14#include <circogen/block.h>
15#include <util/alloc.h>
16
18{
19 bl->first = NULL;
20 bl->last = NULL;
21}
22
24{
25 block_t *sn = gv_alloc(sizeof(block_t));
27 sn->sub_graph = g;
28 return sn;
29}
30
32{
33 if (!sp)
34 return;
35 nodelist_free(&sp->circle_list);
36 free(sp);
37}
38
40{
41 return agnnodes (sp->sub_graph);
42}
43
46{
47 bp->next = NULL;
48 if (bl->last) {
49 bl->last->next = bp;
50 bl->last = bp;
51 } else {
52 bl->first = bp;
53 bl->last = bp;
54 }
55}
56
59{
60 if (bl->first) {
61 bp->next = bl->first;
62 bl->first = bp;
63 } else {
64 bl->first = bp;
65 bl->last = bp;
66 }
67}
68
69#ifdef DEBUG
70void printBlocklist(blocklist_t * snl)
71{
72 block_t *bp;
73 for (bp = snl->first; bp; bp = bp->next) {
74 Agnode_t *n;
75 char *p;
76 Agraph_t *g = bp->sub_graph;
77 fprintf(stderr, "block=%s\n", agnameof(g));
78 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
79 Agedge_t *e;
80 if (PARENT(n))
81 p = agnameof(PARENT(n));
82 else
83 p = "<nil>";
84 fprintf(stderr, " %s (%d %s)\n", agnameof(n), VAL(n), p);
85 for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
86 fprintf(stderr, " %s--", agnameof(agtail(e)));
87 fprintf(stderr, "%s\n", agnameof(aghead(e)));
88 }
89 }
90 }
91}
92#endif
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
Definition alloc.h:47
void insertBlock(blocklist_t *bl, block_t *bp)
add block at beginning
Definition block.c:58
int blockSize(block_t *sp)
Definition block.c:39
void freeBlock(block_t *sp)
Definition block.c:31
void initBlocklist(blocklist_t *bl)
Definition block.c:17
block_t * mkBlock(Agraph_t *g)
Definition block.c:23
void appendBlock(blocklist_t *bl, block_t *bp)
add block at end
Definition block.c:45
#define PARENT(n)
Definition circular.h:84
#define VAL(n)
Definition circular.h:87
void free(void *)
node NULL
Definition grammar.y:163
int agnnodes(Agraph_t *g)
Definition graph.c:169
#define agtail(e)
Definition cgraph.h:880
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Definition edge.c:94
#define aghead(e)
Definition cgraph.h:881
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
Definition edge.c:85
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:158
graph or subgraph
Definition cgraph.h:425
Definition block.h:26
nodelist_t circle_list
Definition block.h:32
blocklist_t children
Definition block.h:33
Agraph_t * sub_graph
Definition block.h:29
block_t * next
Definition block.h:28
block_t * last
Definition block.h:23
block_t * first
Definition block.h:22