From 1ef463901a9a9b04ad1fccd18bd19712fbe39292 Mon Sep 17 00:00:00 2001 From: Emden Gansner Date: Mon, 27 Feb 2012 14:40:27 -0500 Subject: [PATCH] Add a discipline parameter to open function of id and mem disciplines. --- lib/cgraph/cgraph.3 | 4 ++-- lib/cgraph/cgraph.h | 4 ++-- lib/cgraph/graph.c | 4 ++-- lib/cgraph/id.c | 2 +- lib/cgraph/mem.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/cgraph/cgraph.3 b/lib/cgraph/cgraph.3 index 7bb6a520e..c0ebd9d58 100644 --- a/lib/cgraph/cgraph.3 +++ b/lib/cgraph/cgraph.3 @@ -392,7 +392,7 @@ they are mapped to and from strings. .P0 struct Agiddisc_s { /* object ID allocator */ - void *(*open) (Agraph_t * g); /* associated with a graph */ + void *(*open) (Agraph_t * g, Agdisc_t*); /* associated with a graph */ long (*map) (void *state, int objtype, char *str, unsigned long *id, int createflag); long (*alloc) (void *state, int objtype, unsigned long id); void (*free) (void *state, int objtype, unsigned long id); @@ -457,7 +457,7 @@ struct Agiodisc_s { } ; struct Agmemdisc_s { /* memory allocator */ - void *(*open)(void); /* independent of other resources */ + void *(*open)(Agdisc_t*); /* independent of other resources */ void *(*alloc)(void *state, size_t req); void *(*resize)(void *state, void *ptr, size_t old, size_t req); void (*free)(void *state, void *ptr); diff --git a/lib/cgraph/cgraph.h b/lib/cgraph/cgraph.h index a815e8494..ee58898c1 100644 --- a/lib/cgraph/cgraph.h +++ b/lib/cgraph/cgraph.h @@ -148,7 +148,7 @@ struct Agdesc_s { /* graph descriptor */ /* disciplines for external resources needed by libgraph */ struct Agmemdisc_s { /* memory allocator */ - void *(*open) (void); /* independent of other resources */ + void *(*open) (Agdisc_t*); /* independent of other resources */ void *(*alloc) (void *state, size_t req); void *(*resize) (void *state, void *ptr, size_t old, size_t req); void (*free) (void *state, void *ptr); @@ -156,7 +156,7 @@ struct Agmemdisc_s { /* memory allocator */ }; struct Agiddisc_s { /* object ID allocator */ - void *(*open) (Agraph_t * g); /* associated with a graph */ + void *(*open) (Agraph_t * g, Agdisc_t*); /* associated with a graph */ long (*map) (void *state, int objtype, char *str, unsigned long *id, int createflag); long (*alloc) (void *state, int objtype, unsigned long id); diff --git a/lib/cgraph/graph.c b/lib/cgraph/graph.c index 8811b7d13..5a46ac2ab 100644 --- a/lib/cgraph/graph.c +++ b/lib/cgraph/graph.c @@ -28,7 +28,7 @@ static Agclos_t *agclos(Agdisc_t * proto) /* establish an allocation arena */ memdisc = ((proto && proto->mem) ? proto->mem : &AgMemDisc); - memclosure = memdisc->open(); + memclosure = memdisc->open(proto); rv = memdisc->alloc(memclosure, sizeof(Agclos_t)); rv->disc.mem = memdisc; rv->state.mem = memclosure; @@ -54,7 +54,7 @@ Agraph_t *agopen(char *name, Agdesc_t desc, Agdisc_t * arg_disc) g->desc = desc; g->desc.maingraph = TRUE; g->root = g; - g->clos->state.id = g->clos->disc.id->open(g); + g->clos->state.id = g->clos->disc.id->open(g, arg_disc); if (agmapnametoid(g, AGRAPH, name, &gid, TRUE)) AGID(g) = gid; /* else AGID(g) = 0 because we have no alternatives */ diff --git a/lib/cgraph/id.c b/lib/cgraph/id.c index c2fd60d7b..c4b5d71c8 100644 --- a/lib/cgraph/id.c +++ b/lib/cgraph/id.c @@ -16,7 +16,7 @@ /* a default ID allocator that works off the shared string lib */ -static void *idopen(Agraph_t * g) +static void *idopen(Agraph_t * g, Agdisc_t* disc) { return g; } diff --git a/lib/cgraph/mem.c b/lib/cgraph/mem.c index 14dd24128..391b3ac94 100644 --- a/lib/cgraph/mem.c +++ b/lib/cgraph/mem.c @@ -62,7 +62,7 @@ Agmemdisc_t AgMemDisc = /* malloc based allocator */ -static void *memopen(void) +static void *memopen(Agdisc_t* disc) { return NIL(void *); } -- 2.40.0