46 first = d = hdr->
data;
56 if (mtf && hdr->
data != d)
57 agerrorf(
"move to front lock inconsistency");
58 }
else if (d != first || mtf != 0) {
72 newrec->
next = newrec;
74 if (firstrec->
next == firstrec) {
75 firstrec->
next = newrec;
76 newrec->
next = firstrec;
79 firstrec->
next = newrec;
88void *
agbindrec(
void *arg_obj,
const char *recname,
unsigned int recsize,
97 if (rec ==
NULL && recsize > 0) {
112 Agrec_t *rec = arg_rec, *newrec;
113 if (obj->
data == rec) {
114 if (rec->
next == rec)
128 while (
prev->next != rec) {
174 unsigned int rec_size;
175 bool recur = arg_rec_size < 0;
177 rec_size = (
unsigned int) abs(arg_rec_size);
232 if ((rec = obj->
data)) {
238 }
while (rec != obj->
data);
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
void * agalloc(Agraph_t *g, size_t size)
void agfree(Agraph_t *g, void *ptr)
#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