From 8383f33229df2aa718d1a2285977f836f33df1da Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 28 Mar 2006 21:00:00 +0000 Subject: [PATCH] (as_data): Use void * for userdata member and userdata parameter of callbacks. Users changed. --- src/lib/as/as.h | 47 ++++++++++++++++++++++++------------------- src/lib/as/as_init.c | 13 ++++++------ src/lib/common/path.c | 22 +++++++++----------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/lib/as/as.h b/src/lib/as/as.h index 258090df..74bbc83c 100644 --- a/src/lib/as/as.h +++ b/src/lib/as/as.h @@ -30,8 +30,8 @@ #ifndef AS_H #define AS_H -#include /* for FILE */ -#include "misc.h" /* for s_char */ +#include +#include "misc.h" /* * Coordinate. @@ -90,12 +90,17 @@ struct as_data { int maxneighbors; /* max # of neighbors a cell can have */ int hashsize; /* size of internal hash table */ - int (*hash) (struct as_coord); /* hash function (coord -> int) */ - int (*neighbor) (struct as_coord, struct as_coord *, s_char *); /* function to find neighbors */ - double (*lbcost) (struct as_coord, struct as_coord, s_char *); /* function to give lower bound cost */ - double (*realcost) (struct as_coord, struct as_coord, s_char *); /* function to give real cost */ - double (*seccost) (struct as_coord, struct as_coord, s_char *); /* function to secondary cost */ - char *userdata; /* user's data, passed to callbacks */ + /* hash function (coord -> int) */ + int (*hash)(struct as_coord); + /* function to find neighbors */ + int (*neighbor)(struct as_coord, struct as_coord *, void *); + /* function to give lower bound cost */ + double (*lbcost)(struct as_coord, struct as_coord, void *); + /* function to give real cost */ + double (*realcost)(struct as_coord, struct as_coord, void *); + /* function to secondary cost */ + double (*seccost)(struct as_coord, struct as_coord, void *); + void *userdata; /* user's data, passed to callbacks */ struct as_coord from; /* from coordinate */ struct as_coord to; /* to coordinate */ struct as_path *path; /* solution */ @@ -144,20 +149,20 @@ struct as_frompath { /* Functions that the user can call. */ extern struct as_data *as_init(int maxneighbors, int hashsize, - int (*hashfunc) (struct as_coord), - int (*neighborfunc) (struct as_coord, - struct as_coord *, - s_char *), - double (*lbcostfunc) (struct as_coord, - struct as_coord, - s_char *), - double (*realcostfunc) (struct as_coord, - struct as_coord, - s_char *), - double (*seccostfunc) (struct as_coord, + int (*hashfunc)(struct as_coord), + int (*neighborfunc)(struct as_coord, + struct as_coord *, + void *), + double (*lbcostfunc)(struct as_coord, + struct as_coord, + void *), + double (*realcostfunc)(struct as_coord, struct as_coord, - s_char *), - s_char *userdata); + void *), + double (*seccostfunc)(struct as_coord, + struct as_coord, + void *), + void *userdata); extern int as_search(struct as_data *adp); extern void as_delete(struct as_data *adp); extern void as_reset(struct as_data *adp); diff --git a/src/lib/as/as_init.c b/src/lib/as/as_init.c index 28edded2..c02f26e2 100644 --- a/src/lib/as/as_init.c +++ b/src/lib/as/as_init.c @@ -31,13 +31,12 @@ struct as_data * as_init(int maxneighbors, int hashsize, - int (*hashfunc) (struct as_coord), - int (*neighborfunc) (struct as_coord, struct as_coord *, s_char *), - double (*lbcostfunc) (struct as_coord, struct as_coord, s_char *), - double (*realcostfunc) (struct as_coord, struct as_coord, - s_char *), - double (*seccostfunc) (struct as_coord, struct as_coord, s_char *), - s_char *userdata) + int (*hashfunc)(struct as_coord), + int (*neighborfunc)(struct as_coord, struct as_coord *, void *), + double (*lbcostfunc)(struct as_coord, struct as_coord, void *), + double (*realcostfunc)(struct as_coord, struct as_coord, void *), + double (*seccostfunc)(struct as_coord, struct as_coord, void *), + void *userdata) { struct as_data *adp; diff --git a/src/lib/common/path.c b/src/lib/common/path.c index b4d0b39f..d2ad3f4b 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -60,14 +60,10 @@ struct bestp { }; static int bp_path(struct as_path *pp, s_char *buf); -static int bp_neighbors(struct as_coord c, struct as_coord *cp, - s_char *pp); -static double bp_lbcost(struct as_coord from, struct as_coord to, - s_char *pp); -static double bp_realcost(struct as_coord from, struct as_coord to, - s_char *pp); -static double bp_seccost(struct as_coord from, struct as_coord to, - s_char *pp); +static int bp_neighbors(struct as_coord c, struct as_coord *cp, void *); +static double bp_lbcost(struct as_coord from, struct as_coord to, void *); +static double bp_realcost(struct as_coord from, struct as_coord to, void *); +static double bp_seccost(struct as_coord from, struct as_coord to, void *); static int bp_coord_hash(struct as_coord c); /* We use this for caching neighbors. It never changes except @@ -83,7 +79,7 @@ bp_init(void) memset(bp, 0, sizeof(*bp)); bp->adp = as_init(BP_NEIGHBORS, BP_ASHASHSIZE, bp_coord_hash, bp_neighbors, bp_lbcost, bp_realcost, - bp_seccost, (s_char *)bp); + bp_seccost, bp); if (bp->adp == NULL) return NULL; @@ -183,7 +179,7 @@ bp_path(struct as_path *pp, s_char *buf) * XXX need to check ownership, sector types, etc. */ static int -bp_neighbors(struct as_coord c, struct as_coord *cp, s_char *pp) +bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp) { struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache; coord x, y; @@ -238,7 +234,7 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, s_char *pp) */ /*ARGSUSED*/ static double -bp_lbcost(struct as_coord from, struct as_coord to, s_char *pp) +bp_lbcost(struct as_coord from, struct as_coord to, void *pp) { struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache; struct bestp *bp = (struct bestp *)pp; @@ -260,7 +256,7 @@ bp_lbcost(struct as_coord from, struct as_coord to, s_char *pp) * Compute the real cost to move from "from" to "to". */ static double -bp_realcost(struct as_coord from, struct as_coord to, s_char *pp) +bp_realcost(struct as_coord from, struct as_coord to, void *pp) { return bp_lbcost(from, to, pp); } @@ -271,7 +267,7 @@ bp_realcost(struct as_coord from, struct as_coord to, s_char *pp) */ /*ARGSUSED*/ static double -bp_seccost(struct as_coord from, struct as_coord to, s_char *pp) +bp_seccost(struct as_coord from, struct as_coord to, void *pp) { return (double)mapdist((coord)from.x, (coord)from.y, (coord)to.x, (coord)to.y);