47 first = d = hdr->
data;
57 if (mtf && hdr->
data != d)
58 agerrorf(
"move to front lock inconsistency");
59 }
else if (d != first || mtf != 0) {
73 newrec->
next = newrec;
75 if (firstrec->
next == firstrec) {
76 firstrec->
next = newrec;
77 newrec->
next = firstrec;
80 firstrec->
next = newrec;
89void *
agbindrec(
void *arg_obj,
const char *recname,
unsigned int recsize,
98 if (rec ==
NULL && recsize > 0) {
113 Agrec_t *rec = arg_rec, *newrec;
114 if (obj->
data == rec) {
115 if (rec->
next == rec)
129 while (
prev->next != rec) {
175 unsigned int rec_size;
176 bool recur = arg_rec_size < 0;
178 rec_size = (
unsigned int) abs(arg_rec_size);
184 aginit(
s,kind,rec_name,arg_rec_size,mtf);
233 if ((rec = obj->
data)) {
239 }
while (rec != obj->
data);
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
#define agopp(e)
opposite edge: flip Agedgepair_s.out ⇄ Agedgepair_s.in/*#end#*/
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
void agerrorf(const char *fmt,...)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agraph_t * agraphof(void *obj)
#define AGDATA(obj)
returns Agrec_t
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Agraph_t * agroot(void *obj)
Agrec_t * aggetrec(void *obj, const char *name, int mtf)
find record in circular list and do optional move-to-front and lock
void aginit(Agraph_t *g, int kind, const char *rec_name, int arg_rec_size, int mtf)
attach new records to objects of specified kind
void * agbindrec(void *arg_obj, const char *recname, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
void agclean(Agraph_t *g, int kind, char *rec_name)
calls agdelrec for all objects of the same class in an entire graph
int agdelrec(void *arg_obj, const char *name)
deletes a named record from one object
int agstrfree(Agraph_t *, const char *)
char * agstrdup(Agraph_t *, const char *)
returns a pointer to a reference-counted copy of the argument string, creating one if necessary
Agraph_t * agfstsubg(Agraph_t *g)
Agraph_t * agnxtsubg(Agraph_t *subg)
void agrecclose(Agobj_t *obj)
static void objdelrec(Agraph_t *g, Agobj_t *obj, void *arg_rec)
static void listdelrec(Agobj_t *obj, Agrec_t *rec)
static void simple_delrec(Agraph_t *g, Agobj_t *obj, void *rec_name)
static void objputrec(Agobj_t *obj, void *arg)
static void set_data(Agobj_t *obj, Agrec_t *data, bool mtflock)
static bool streq(const char *a, const char *b)
are a and b equal?
a generic header of Agraph_s, Agnode_s and Agedge_s
Agrec_t * data
stores programmer-defined data, access with AGDATA
Agtag_t tag
access with AGTAG
implementation of Agrec_t
Agrec_t * next
circular linked list of records
unsigned objtype
access with AGTYPE
unsigned mtflock
move-to-front lock, guards Agobj_s::data