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