Graphviz 13.1.3~dev.20250829.1031
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#include <util/list.h>
17
19{
20 bl->first = NULL;
21 bl->last = NULL;
22}
23
25{
26 block_t *sn = gv_alloc(sizeof(block_t));
28 sn->sub_graph = g;
29 return sn;
30}
31
33{
34 if (!sp)
35 return;
37 free(sp);
38}
39
41{
42 return agnnodes (sp->sub_graph);
43}
44
47{
48 bp->next = NULL;
49 if (bl->last) {
50 bl->last->next = bp;
51 bl->last = bp;
52 } else {
53 bl->first = bp;
54 bl->last = bp;
55 }
56}
57
60{
61 if (bl->first) {
62 bp->next = bl->first;
63 bl->first = bp;
64 } else {
65 bl->first = bp;
66 bl->last = bp;
67 }
68}
69
70#ifdef DEBUG
71void printBlocklist(blocklist_t * snl)
72{
73 block_t *bp;
74 for (bp = snl->first; bp; bp = bp->next) {
75 Agnode_t *n;
76 char *p;
77 Agraph_t *g = bp->sub_graph;
78 fprintf(stderr, "block=%s\n", agnameof(g));
79 for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
80 Agedge_t *e;
81 if (PARENT(n))
82 p = agnameof(PARENT(n));
83 else
84 p = "<nil>";
85 fprintf(stderr, " %s (%d %s)\n", agnameof(n), VAL(n), p);
86 for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
87 fprintf(stderr, " %s--", agnameof(agtail(e)));
88 fprintf(stderr, "%s\n", agnameof(aghead(e)));
89 }
90 }
91 }
92}
93#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:59
int blockSize(block_t *sp)
Definition block.c:40
void freeBlock(block_t *sp)
Definition block.c:32
void initBlocklist(blocklist_t *bl)
Definition block.c:18
block_t * mkBlock(Agraph_t *g)
Definition block.c:24
void appendBlock(blocklist_t *bl, block_t *bp)
add block at end
Definition block.c:46
#define PARENT(n)
Definition circular.h:84
#define VAL(n)
Definition circular.h:87
void free(void *)
node NULL
Definition grammar.y:181
int agnnodes(Agraph_t *g)
Definition graph.c:155
#define agtail(e)
Definition cgraph.h:988
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Definition edge.c:96
#define aghead(e)
Definition cgraph.h:989
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
Definition edge.c:87
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:48
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:41
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:143
type-generic dynamically expanding list
#define LIST_FREE(list)
Definition list.h:379
graph or subgraph
Definition cgraph.h:424
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