From: ellson Date: Tue, 18 Oct 2005 18:45:53 +0000 (+0000) Subject: Fix some uninitialized variables; X-Git-Tag: LAST_LIBGRAPH~32^2~7277 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93e9f0d258d3eb37e012b8c1eb0b2531962b1740;p=graphviz Fix some uninitialized variables; replace raw use of fprintf(stderr,.. with agerr() replace raw use of *alloc with graphviz versions --- diff --git a/cmd/dot/dot.c b/cmd/dot/dot.c index 50abf6093..d9ba85279 100644 --- a/cmd/dot/dot.c +++ b/cmd/dot/dot.c @@ -144,7 +144,8 @@ int main(int argc, char **argv) #endif if (MemTest) { - while (1) { + int i = 2; + while (i--) { /* Create a test graph */ G = create_test_graph(); @@ -155,7 +156,9 @@ int main(int argc, char **argv) /* Delete graph */ agclose(G); } +#if 0 assert(0); /* should never exit loop */ +#endif } else { while ((G = next_input_graph())) { if (prev) { diff --git a/cmd/gvpr/compile.c b/cmd/gvpr/compile.c index 94f555816..e89ce3d3a 100644 --- a/cmd/gvpr/compile.c +++ b/cmd/gvpr/compile.c @@ -968,7 +968,6 @@ setval(Expr_t * pgm, Exnode_t * x, Exid_t * sym, Exref_t * ref, { Gpr_t *state; Agobj_t *objp; - Agsym_t *gsym; Agnode_t *np; int iv; int rv = 0; @@ -1024,7 +1023,7 @@ setval(Expr_t * pgm, Exnode_t * x, Exid_t * sym, Exref_t * ref, } - return setattr(objp, gsym->name, v.string); + return setattr(objp, sym->name, v.string); } static int codePhase; diff --git a/lib/common/emit.c b/lib/common/emit.c index 75b882415..4e6fbbb3b 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1613,7 +1613,7 @@ void use_library(char *name) static void emit_job(GVJ_t * job, graph_t * g) { if (!GD_drawing(g)) { - fprintf (stderr,"layout was not done\n"); + agerr (AGERR, "layout was not done\n"); return; } @@ -1767,7 +1767,7 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g) GVJ_t *job; if (!GD_drawing(g)) { - fprintf(stderr, "Layout was not done. Missing layout plugins? \n"); + agerr (AGERR, "Layout was not done. Missing layout plugins? \n"); return -1; } @@ -1790,7 +1790,7 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g) } job->output_lang = gvrender_select(job, job->output_langname); if (job->output_lang == NO_SUPPORT) { - fprintf(stderr,"renderer for %s is unavailable\n", job->output_langname); + agerr (AGERR, "renderer for %s is unavailable\n", job->output_langname); return -1; } diff --git a/lib/common/geom.c b/lib/common/geom.c index 7d55efe43..7cddab5aa 100644 --- a/lib/common/geom.c +++ b/lib/common/geom.c @@ -19,6 +19,8 @@ #include #include "geom.h" +#include "types.h" +#include "graph.h" #include "geomprocs.h" point pointof(int x, int y) @@ -369,7 +371,7 @@ point ccwrotatep(point p, int ccwrot) p.y = x; break; default: - fprintf(stderr,"unsupported ccw rotation: %d degrees\n", ccwrot); + agerr (AGWARN, "unsupported ccw rotation: %d degrees\n", ccwrot); } return p; } @@ -393,7 +395,7 @@ pointf ccwrotatepf(pointf p, int ccwrot) p.y = x; break; default: - fprintf(stderr,"unsupported ccw rotation: %d degrees\n", ccwrot); + agerr (AGWARN, "unsupported ccw rotation: %d degrees\n", ccwrot); } return p; } @@ -417,7 +419,7 @@ point cwrotatep(point p, int cwrot) p.y = x; break; default: - fprintf(stderr,"unsupported cw rotation: %d degrees\n", cwrot); + agerr (AGWARN, "unsupported cw rotation: %d degrees\n", cwrot); } return p; } @@ -441,7 +443,7 @@ pointf cwrotatepf(pointf p, int cwrot) p.y = x; break; default: - fprintf(stderr,"unsupported cw rotation: %d degrees\n", cwrot); + agerr (AGWARN, "unsupported cw rotation: %d degrees\n", cwrot); } return p; } diff --git a/lib/common/splines.c b/lib/common/splines.c index 1b050c1cc..1849aef5d 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -725,6 +725,7 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, bool merge) } break; } + for (orig = e; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig)); if (n == orig->head) ED_head_port(orig).clip = FALSE; else diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index c2c95e7e3..8a26152ee 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -813,6 +813,7 @@ allocate_ranks(graph_t * g) GD_rank(g)[r].an = GD_rank(g)[r].n = cn[r]; GD_rank(g)[r].av = GD_rank(g)[r].v = N_NEW(cn[r] + 1, node_t *); } + free (cn); } /* install a node at the current right end of its rank */ diff --git a/lib/gvc/gvc.c b/lib/gvc/gvc.c index 376aede18..872aed5b9 100644 --- a/lib/gvc/gvc.c +++ b/lib/gvc/gvc.c @@ -49,7 +49,7 @@ int gvLayout(GVC_t *gvc, graph_t *g, char *engine) } rc = gvlayout_select(gvc, engine); if (rc == NO_SUPPORT) { - fprintf(stderr, "Layout type: \"%s\" not recognized. Use one of:%s\n", + agerr (AGERR, "Layout type: \"%s\" not recognized. Use one of:%s\n", engine, gvplugin_list(gvc, API_layout, engine)); return -1; } @@ -85,7 +85,7 @@ int gvRender(GVC_t *gvc, graph_t *g, char *format, FILE *out) /* create a job for the required format */ rc = gvrender_output_langname_job(gvc, format); if (rc == NO_SUPPORT) { - fprintf(stderr, "Renderer type: \"%s\" not recognized. Use one of:%s\n", + agerr (AGERR, "Renderer type: \"%s\" not recognized. Use one of:%s\n", format, gvplugin_list(gvc, API_render, format)); return -1; } diff --git a/lib/gvc/gvconfig.c b/lib/gvc/gvconfig.c index b2b2c0b1e..8f86de940 100644 --- a/lib/gvc/gvconfig.c +++ b/lib/gvc/gvconfig.c @@ -31,6 +31,7 @@ #include "geom.h" #include "color.h" +#include "memory.h" #include "const.h" #include "types.h" @@ -291,7 +292,7 @@ static void config_rescan(GVC_t *gvc, char *config_path) libdir = gvconfig_libdir(); /* load all libraries even if can't save config */ - config_glob = malloc(strlen(libdir) + config_glob = gmalloc(strlen(libdir) + 1 + strlen(plugin_glob) + 1); @@ -483,7 +484,7 @@ void gvconfig(GVC_t * gvc, bool rescan) } if (! gvc->config_path) { - gvc->config_path = malloc(strlen(libdir) + 1 + strlen(config_file_name) + 1); + gvc->config_path = gmalloc(strlen(libdir) + 1 + strlen(config_file_name) + 1); strcpy(gvc->config_path, libdir); strcat(gvc->config_path, "/"); strcat(gvc->config_path, config_file_name); @@ -511,7 +512,7 @@ void gvconfig(GVC_t * gvc, bool rescan) agerr (AGERR,"failed to open %s for read.\n", gvc->config_path); } else { - config_text = malloc(config_st.st_size + 1); + config_text = gmalloc(config_st.st_size + 1); sz = fread(config_text, 1, config_st.st_size, f); if (sz == 0) { agerr(AGERR,"%s is zero sized, or other read error.\n", gvc->config_path); diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index 2e4aeaae0..f4c7c53a7 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -27,6 +27,7 @@ #endif #include "geom.h" +#include "memory.h" #include "types.h" #include "graph.h" @@ -88,7 +89,7 @@ bool gvplugin_install(GVC_t * gvc, api_t api, while (*pnext && strcmp(typestr, (*pnext)->typestr) == 0 && quality < (*pnext)->quality) pnext = &((*pnext)->next); - plugin = malloc(sizeof(gvplugin_available_t)); + plugin = GNEW(gvplugin_available_t); plugin->next = *pnext; *pnext = plugin; plugin->typestr = typestr; @@ -117,9 +118,9 @@ gvplugin_library_t *gvplugin_library_load(char *path) if (len > lenp) { lenp = len+20; if (p) - p = realloc(p, lenp); + p = grealloc(p, lenp); else - p = malloc(lenp); + p = gmalloc(lenp); } if (path[0] == '/') { @@ -146,7 +147,7 @@ gvplugin_library_t *gvplugin_library_load(char *path) agerr (AGERR,"invalid plugin path \"%s\"\n", p); return NULL; } - sym = malloc(len + strlen(suffix) + 1); + sym = gmalloc(len + strlen(suffix) + 1); strcpy(sym, s+4); /* strip leading "/lib" */ s = strchr(sym, '.'); /* strip trailing ".so.0" */ strcpy(s,suffix); /* append "_LTX_library" */ @@ -267,7 +268,7 @@ static const char *append_buf(char sep, char *str, bool new) len = strlen(str) + 1; if (bufsz < (pos + len + 1)) { bufsz += 4 * len; - buf = realloc(buf, bufsz); + buf = grealloc(buf, bufsz); } p = buf + pos; *p++ = sep; diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index f5ab323a8..0db8388b1 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -30,6 +30,7 @@ #include #include "geom.h" +#include "memory.h" #include "pathplan.h" #include "color.h" #include "const.h" @@ -205,7 +206,7 @@ static void gvrender_resolve_color(gvrender_features_t * features, rc = colorxlate(name, color, features->color_type); if (rc != COLOR_OK) { if (rc == COLOR_UNKNOWN) { - char *missedcolor = malloc(strlen(name) + 16); + char *missedcolor = gmalloc(strlen(name) + 16); sprintf(missedcolor, "color %s", name); if (emit_once(missedcolor)) agerr(AGWARN, "%s is not a known color.\n", name); @@ -816,7 +817,7 @@ void gvrender_polygon(GVJ_t * job, point * A, int n, int filled) int i; if (sizeAF < n) - AF = realloc(AF, n * sizeof(pointf)); + AF = grealloc(AF, n * sizeof(pointf)); /* end hack */ for (i = 0; i < n; i++) AF[i] = gvrender_pt(job, A[i]); @@ -845,7 +846,7 @@ void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n, int i; if (szAF2 < n) { - AF2 = realloc(AF2, n * sizeof(pointf)); + AF2 = grealloc(AF2, n * sizeof(pointf)); szAF2 = n; } for (i = 0; i < n; i++) @@ -862,7 +863,7 @@ void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n, int i; if (szA < n) { - A = realloc(A, n * sizeof(point)); + A = grealloc(A, n * sizeof(point)); szA = n; } for (i = 0; i < n; i++) @@ -886,7 +887,7 @@ void gvrender_polyline(GVJ_t * job, point * A, int n) int i; if (szAF < n) { - AF = realloc(AF, n * sizeof(pointf)); + AF = grealloc(AF, n * sizeof(pointf)); szAF = n; } for (i = 0; i < n; i++) @@ -935,7 +936,7 @@ void gvrender_user_shape(GVJ_t * job, char *name, point * A, int n, int i; if (szAF < n) { - AF = realloc(AF, n * sizeof(pointf)); + AF = grealloc(AF, n * sizeof(pointf)); szAF = n; } for (i = 0; i < n; i++)