]> granicus.if.org Git - graphviz/commitdiff
remove unnecessary guards on calls to free()
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Oct 2020 00:04:48 +0000 (17:04 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 29 Oct 2020 00:13:12 +0000 (17:13 -0700)
Freeing NULL is a no-op, so there is no need for these extra conditionals.

46 files changed:
cmd/gvmap/gvmap.c
cmd/lefty/common.c
cmd/lefty/txtview.c
cmd/tools/bcomps.c
cmd/tools/graphml2gv.c
cmd/tools/gv2gxl.c
cmd/tools/gvpack.c
cmd/tools/gxl2gv.c
lib/ast/pathpath.c
lib/common/emit.c
lib/common/htmlparse.y
lib/common/htmltable.c
lib/common/input.c
lib/common/labels.c
lib/common/psusershape.c
lib/common/shapes.c
lib/common/textspan.c
lib/common/types.h
lib/common/utils.c
lib/dotgen/aspect.c
lib/dotgen/dotinit.c
lib/fdpgen/layout.c
lib/glcomp/glcompfont.c
lib/glcomp/glcomplabel.c
lib/glcomp/glcomptext.c
lib/glcomp/glcomptexture.c
lib/glcomp/glutils.c
lib/gvc/gvconfig.c
lib/gvc/gvcontext.c
lib/gvc/gvevent.c
lib/gvc/gvjobs.c
lib/neatogen/adjust.c
lib/neatogen/delaunay.c
lib/neatogen/dijkstra.c
lib/neatogen/lu.c
lib/neatogen/neatoinit.c
lib/ortho/ortho.c
lib/osage/osageinit.c
lib/pathplan/cvt.c
lib/sfdpgen/PriorityQueue.c
lib/sfio/sfclose.c
lib/sfio/sfmode.c
lib/sfio/sfvprintf.c
lib/sfio/sfvscanf.c
plugin/gd/gvrender_gd.c
tclpkg/tclpathplan/tclpathplan.c

index 8de13a610fbeae9461b04602adbfc375332512f3..9599b26af0edad760f796aeb1ce12c2f23f11b5b 100644 (file)
@@ -382,7 +382,7 @@ init(int argc, char **argv, params_t* pm)
       }
       break;
     case 'l':
-      if (pm->plot_label) free (pm->plot_label);
+      free (pm->plot_label);
       pm->plot_label = strdup (optarg);
       break;
     case ':':
index 9a3796914876ebcc292ea6b45a1e0eba9cb612be..9deae88aaaccf454003e1ab82cad45f82df301b3 100644 (file)
@@ -147,12 +147,9 @@ int init (char *aout) {
 }
 
 void term (void) {
-    if (lpathp)
-        free (lpathp);
-    if (pathp)
-        free (pathp);
-    if (cmdp)
-        free (cmdp);
+    free (lpathp);
+    free (pathp);
+    free (cmdp);
 }
 
 /*  given a file name, it looks for this file in LEFTYPATH
index 974c1c28336fe5348752049b783279cef3feab42..f3a4999e2c9b8476951c080de75c1962c16f9cf8 100644 (file)
@@ -531,18 +531,15 @@ static void fillnode (txtnode_t *pnode, txtnode_t *cnode) {
 static void unfillnode (txtnode_t *cnode) {
     int i;
 
-    if (cnode->path)
-        free (cnode->path), cnode->path = NULL;
+    free (cnode->path), cnode->path = NULL;
     switch (cnode->mode) {
     case TXT_SEEN:
-        if (cnode->u.s.text)
-            free (cnode->u.s.text);
+        free (cnode->u.s.text);
         if (cnode->u.s.wi)
             Gdestroywidget (cnode->u.s.wi);
         break;
     case TXT_ABSTRACT:
-        if (cnode->u.a.text)
-            free (cnode->u.a.text);
+        free (cnode->u.a.text);
         if (cnode->u.a.wi)
             Gdestroywidget (cnode->u.a.wi);
         break;
@@ -550,18 +547,15 @@ static void unfillnode (txtnode_t *cnode) {
         if (cnode->ttype == T_TABLE) {
             for (i = 0; i < cnode->u.f.t.n; i++)
                 unfillnode (&cnode->u.f.t.list[i]);
-            if (cnode->u.f.t.list)
-                free (cnode->u.f.t.list);
-            if (cnode->u.f.t.ftext)
-                free (cnode->u.f.t.ftext);
+            free (cnode->u.f.t.list);
+            free (cnode->u.f.t.ftext);
             if (cnode->u.f.t.fwi) {
                 Gdestroywidget (cnode->u.f.t.fwi);
                 Gdestroywidget (cnode->u.f.t.mwi);
                 Gdestroywidget (cnode->u.f.t.lwi);
             }
         } else {
-            if (cnode->u.f.s.text)
-                free (cnode->u.f.s.text);
+            free (cnode->u.f.s.text);
             if (cnode->u.f.s.wi)
                 Gdestroywidget (cnode->u.f.s.wi);
         }
index 584c57fc5bdf93fb6cd0e390445442fe6b10da18..acd4a56418071758a99fde139362d48f191ae402 100644 (file)
@@ -95,8 +95,7 @@ static char *blockName(char *gname, int d)
 
     sz = strlen(gname) + 128;
     if (sz > bufsz) {
-       if (buf)
-           free(buf);
+       free(buf);
        buf = malloc(sz);
     }
 
index da32439c130bf68d6aa884dea66dc0ea81b176f2..061bd45a87d7f69c64a81baff6a7740f890cd331 100644 (file)
@@ -586,8 +586,7 @@ static void endElementHandler(void *userData, const char *name)
            setGraphAttr(G, name, value, ud);
            break;
        }
-       if (dynbuf)
-           free(dynbuf);
+       free(dynbuf);
        ud->globalAttrType = TAG_NONE;
     } 
 }
index 1e0b600d3d5bb46a2f4bcdcffcd403a706f8e016..58ed04021341822f12c308eb7fa82f61c4f061b5 100644 (file)
@@ -524,8 +524,7 @@ writeHdr(gxlstate_t * stp, Agraph_t * g, FILE * gxlFile, int top)
 
        tabover(gxlFile);
        fprintf(gxlFile, "<node id=\"%s\">\n", bp);
-       if (dynbuf)
-           free(dynbuf);
+       free(dynbuf);
        Level++;
     } else {
        Tailport = agattr(g, AGEDGE, "tailport", NIL(char *));
index 42f25eae204bbd6e7a098320599228685f9197d9..43cce0ff8f8bfff57a86b78c9bffd7dfcbefe3bb 100644 (file)
@@ -558,7 +558,7 @@ static char *xName(Dt_t * names, char *oldname)
        p->cnt++;
        len = strlen(oldname) + 100; /* 100 for "_gv" and decimal no. */
        if (namelen < len) {
-           if (name) free (name);
+           free (name);
            name = N_NEW(len, char);
            namelen = len;
        }
index c34adfc630f31a17af9fcab597c8d37320e06df0..9ceef4b348106a23bfae0344f99ba68e2d10d90e 100644 (file)
@@ -628,8 +628,7 @@ static void endElementHandler(void *userData, const char *name)
            setGraphAttr(G, name, value, ud);
            break;
        }
-       if (dynbuf)
-           free(dynbuf);
+       free(dynbuf);
        ud->globalAttrType = TAG_NONE;
     } else if (strcmp(name, "string") == 0
               || strcmp(name, "bool") == 0
index 2e83125647090e8cd8497ba0b47c4b1abed22785..bddb9e6bee4a559e345d69c358cc19e9962d6896 100644 (file)
@@ -46,8 +46,7 @@ char *pathpath(char *path, const char *p, const char *a, int mode)
     if (!path)
        path = buf;
     if (!p) {
-       if (cmd)
-           free(cmd);
+       free(cmd);
        cmd = a ? strdup(a) : (char *) 0;
        return 0;
     }
index b9b333316072011c8fc87501f0e0db830257e2c8..97914b99af8c7e1615383c947ecf58b192c29d4d 100644 (file)
@@ -1194,18 +1194,12 @@ static void init_layering(GVC_t * gvc, graph_t * g)
     char *str;
 
     /* free layer strings and pointers from previous graph */
-    if (gvc->layers) {
-       free(gvc->layers);
-       gvc->layers = NULL;
-    }
-    if (gvc->layerIDs) {
-       free(gvc->layerIDs);
-       gvc->layerIDs = NULL;
-    }
-    if (gvc->layerlist) {
-       free(gvc->layerlist);
-       gvc->layerlist = NULL;
-    }
+    free(gvc->layers);
+    gvc->layers = NULL;
+    free(gvc->layerIDs);
+    gvc->layerIDs = NULL;
+    free(gvc->layerlist);
+    gvc->layerlist = NULL;
     if ((str = agget(g, "layers")) != 0) {
        gvc->numLayers = parse_layers(gvc, g, str);
        if (((str = agget(g, "layerselect")) != 0) && *str) {
@@ -2745,7 +2739,7 @@ emit_edge_label(GVJ_t* job, textlabel_t* lbl, emit_state_t lkind, int explicit,
        }
        gvrender_end_anchor(job);
     }
-    if (newid) free (newid);
+    free (newid);
     job->obj->emit_state = old_emit_state;
 }
 
index e8b3fee492fad6a130ccab67ca2957cff68dc6a2..e34dd8d1578cb3e50856aadac0a090c490e2ffb3 100644 (file)
@@ -132,8 +132,7 @@ typedef struct {
 static void 
 free_fitem(Dt_t* d, fitem* p, Dtdisc_t* ds)
 {
-    if (p->ti.str)
-       free (p->ti.str);
+    free (p->ti.str);
     free (p);
 }
 
index a01fd8bf11834a0e60d5ca88fdfca92d451f4821..b4758d39a0ba3dc41a1d512aa3cdaca85ba49a62 100644 (file)
@@ -813,16 +813,14 @@ void free_html_text(htmltxt_t * t)
     for (i = 0; i < t->nspans; i++) {
        ti = tl->items;
        for (j = 0; j < tl->nitems; j++) {
-           if (ti->str)
-               free(ti->str);
+           free(ti->str);
            if (ti->layout && ti->free_layout)
                ti->free_layout(ti->layout);
            ti++;
        }
        tl++;
     }
-    if (t->spans)
-       free(t->spans);
+    free(t->spans);
     free(t);
 }
 
index 003268f029ef74e7a33b935f489f3e13e19af601..4c0536db943a8a4adae66bb055d08d05bb1f1654 100644 (file)
@@ -881,7 +881,7 @@ void graph_cleanup(graph_t *g)
 {
     if (GD_drawing(g) && GD_drawing(g)->xdots)
        freeXDot ((xdot*)GD_drawing(g)->xdots);
-    if (GD_drawing(g) && GD_drawing(g)->id)
+    if (GD_drawing(g))
        free (GD_drawing(g)->id);
     free(GD_drawing(g));
     GD_drawing(g) = NULL;
index 7339590b072b6b83c02424a3f3c7d163ac8828de..61aca92ed332bd1776dcb74b7d5591af2c2d626f 100644 (file)
@@ -197,7 +197,7 @@ void free_textspan(textspan_t * tl, int cnt)
 
     if (!tl) return;
     for (i = 0; i < cnt; i++) { 
-       if ((i == 0) && tlp->str)
+       if (i == 0)
            free(tlp->str);
        if (tlp->layout && tlp->free_layout)
            tlp->free_layout (tlp->layout);
index 6be0f84a3a40efa4e18465e090f228420c92944e..515ffc42ef71df48ceb0b4fb45c2b341f0c1b2e1 100644 (file)
@@ -122,8 +122,7 @@ void epsf_init(node_t * n)
 void epsf_free(node_t * n)
 {
 
-    if (ND_shape_info(n))
-       free(ND_shape_info(n));
+    free(ND_shape_info(n));
 }
 
 
index de7a898e900d8020d6ff22a53d91d0a8c02a8a59..6641a6ca01a4ed142de86d2f30fb1246d90bcd79 100644 (file)
@@ -3789,7 +3789,7 @@ static void record_gencode(GVJ_t * job, node_t * n)
 
     gen_fields(job, n, f);
 
-    if (clrs[0]) free (clrs[0]);
+    free (clrs[0]);
 
     if (doMap) {
        if (job->flags & EMIT_CLUSTERS_LAST)
index 8038eaa03b5e3d06d2399cbe2c6ef4df882fde5e..bd57c40189be47586aac34e32ed8016186172e1c 100644 (file)
@@ -248,8 +248,8 @@ static void textfont_freef(Dt_t* dt, void* obj, Dtdisc_t* disc)
 {
     textfont_t *f = (textfont_t*)obj;
 
-    if (f->name) free(f->name);
-    if (f->color) free(f->color);
+    free(f->name);
+    free(f->color);
     free(f);
 }
 
index 244408432a314e9a3dc940ce85f6f2ce45711acb..74dc0d5f0158d2dff15ab02a47f16245f29b1c86 100644 (file)
@@ -271,7 +271,7 @@ extern "C" {
 #define elist_fastapp(item,L) do {L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
 #define elist_append(item,L)  do {L.list = ALLOC(L.size + 2,L.list,edge_t*); L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
 #define alloc_elist(n,L)      do {L.size = 0; L.list = N_NEW(n + 1,edge_t*); } while (0)
-#define free_list(L)          do {if (L.list) free(L.list);} while (0)
+#define free_list(L)          free(L.list)
 
 typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind;
 
index 826e69976ab1b5262ee7b9a1574d6cd100c5669c..1936a837a45e99202c5020950c499873ff4d79b1 100644 (file)
@@ -1905,7 +1905,7 @@ void gv_cleanup_edge(edge_t * e)
 
 void gv_cleanup_node(node_t * n)
 {
-    if (ND_pos(n)) free(ND_pos(n));
+    free(ND_pos(n));
     if (ND_shape(n))
         ND_shape(n)->fns->freefn(n);
     free_label(ND_label(n));
index 6d56d5553d35aaeab565208e86e91addbc0d2160..2ffb1ef87a8dba00f3e8125e52483375ecf075a2 100644 (file)
@@ -187,8 +187,7 @@ static void computeLayerWidths(graph_t * g)
                }
                free(layerWidthInfo[i].nodeGroupsInLayer);
            }
-           if (layerWidthInfo[i].removed)
-               free(layerWidthInfo[i].removed);
+           free(layerWidthInfo[i].removed);
        }
 
        free(layerWidthInfo);
index 7b65868e90c1e6527664b8ac7d55a8643d1cbb32..0663a824c44e564b9ca91b1bfabe8cf5f6b77fc9 100644 (file)
@@ -145,8 +145,8 @@ dot_cleanup_graph(graph_t * g)
        dot_cleanup_graph(subg);
     }
     if (! agbindrec(g, "Agraphinfo_t", 0, TRUE)) return;
-    if (GD_clust(g)) free (GD_clust(g));
-    if (GD_rankleader(g)) free (GD_rankleader(g));
+    free (GD_clust(g));
+    free (GD_rankleader(g));
 
     free_list(GD_comp(g));
     if (GD_rank(g)) {
index 9cb8cf129db54ff3118ce189c53e1a8edf697c1a..a1ad9178cc7099ec1858fcb779c4e601954c27cf 100644 (file)
@@ -934,8 +934,7 @@ void layout(graph_t * g, layout_info * infop)
            bp = 0;
        infop->pack.fixed = bp;
        pts = putGraphs(c_cnt, cc, NULL, &infop->pack);
-       if (bp)
-           free(bp);
+       free(bp);
     } else {
        pts = NULL;
        if (c_cnt == 1)
index 91f7ca966364012e3025625d627ddafdf26b958f..f777a5abc8136675707185209c2527b806289fd5 100644 (file)
@@ -184,8 +184,7 @@ static glCompFont *glut_font_init(void)
 #endif
 void glDeleteFont(glCompFont * f)
 {
-    if (f->fontdesc)
-       free(f->fontdesc);
+    free(f->fontdesc);
     if (f->tex)
        glCompDeleteTexture(f->tex);
     free(f);
index cbf1b3a9cc5021c61a22513a8aa071384c5677be..18e3353dc5dbcd88a1e0f865e5ae95c55af62bdd 100644 (file)
@@ -67,8 +67,7 @@ static void update_font(glCompLabel * p,char* text,char* desc,int fs)
     p->common.font=glNewFont (p->common.compset,text,&p->common.color,temp->type,desc,fs,temp->is2D);
     if(temp)
        glDeleteFont(temp);
-    if(p->text)
-       free(p->text);
+    free(p->text);
     p->text = strdup(text);
 
 
index 3a9062b165ce84dc3019fee9ef2ea57bf41b183a..a27c41350418ca6be1f36f3f35fc63274acaf4ac 100644 (file)
@@ -291,8 +291,7 @@ void copy_font(glCompText * targetfont, const glCompText * sourcefont)
     targetfont->tIncX = sourcefont->tIncX;
     targetfont->tIncY = sourcefont->tIncY;
     targetfont->texId = sourcefont->texId;
-    if (targetfont->fontdesc)
-       free(targetfont->fontdesc);
+    free(targetfont->fontdesc);
     if (sourcefont->fontdesc != (char *) 0)
        targetfont->fontdesc = strdup(sourcefont->fontdesc);
     else
@@ -402,8 +401,7 @@ void free_font_set(fontset_t * fontset)
     if (fontset->font_directory)
        rmdir(fontset->font_directory);
 #endif
-    if (fontset->font_directory)
-       free(fontset->font_directory);
+    free(fontset->font_directory);
     free(fontset);
 }
 
index d3402bf3c2762f4dc486a0dfde57f40d46368022..ed740ee88ab382b6f03efd5a7914edd7f71d4e68 100644 (file)
@@ -162,12 +162,9 @@ void glCompDeleteTexture(glCompTex * t)
        return;
     t->userCount--;
     if (!t->userCount) {
-       if (t->data)
-           free(t->data);
-       if (t->def)
-           free(t->def);
-       if (t->text)
-           free(t->text);
+       free(t->data);
+       free(t->def);
+       free(t->text);
        free(t);
     }
 }
index 058ed3e87d7761198ce505a56408398e1c4de310..fad34ae07dacd6d26efc1869c3b41b5432cb42a6 100644 (file)
@@ -413,8 +413,7 @@ void make_plane(glCompPoint a, glCompPoint b, glCompPoint c, plane * P)
 void replacestr(char *source, char **target)
 {
 
-    if (*target)
-       free(*target);
+    free(*target);
     *target = strdup(source);
 }
 
index 78eecfa5b1a1644f76d17b5afd79ed1f7165d9d9..9b0f1ac4e31fd37ec0bca9973a57cd266e6a4f62 100644 (file)
@@ -615,8 +615,7 @@ globfree (glob_t* pglob)
     int i;
     for (i = 0; i < pglob->gl_pathc; i++)
       free (pglob->gl_pathv[i]);
-    if (pglob->gl_pathv)
-               free (pglob->gl_pathv);
+    free (pglob->gl_pathv);
 }
 #endif
 #endif
index cff05cdd6fa2139baee8ca08108125244f60b9eb..0c7966a1276d92297683e5fa180a00b7608fd927 100644 (file)
@@ -95,10 +95,8 @@ int gvFreeContext(GVC_t * gvc)
        free(package);
     }
     gvjobs_delete(gvc);
-    if (gvc->config_path)
-       free(gvc->config_path);
-    if (gvc->input_filenames)
-       free(gvc->input_filenames);
+    free(gvc->config_path);
+    free(gvc->input_filenames);
     textfont_dict_close(gvc);
     for (i = 0; i != num_apis; ++i) {
        for (api = gvc->apis[i]; api != NULL; api = api_next) {
index f1a7ec62bd35755a80b4ec988b52e40d1960e40b..fc68bba400d8d13dfd75299009098a9949750aaa 100644 (file)
@@ -248,10 +248,8 @@ static void gvevent_enter_obj(GVJ_t * job)
     node_t *n;
     Agsym_t *a;
 
-    if (job->active_tooltip) {
-       free(job->active_tooltip);
-       job->active_tooltip = NULL;
-    }
+    free(job->active_tooltip);
+    job->active_tooltip = NULL;
     obj = job->current_obj;
     if (obj) {
         switch (agobjkind(obj)) {
@@ -347,10 +345,8 @@ static void gvevent_select_current_obj(GVJ_t * job)
         }
     }
 
-    if (job->selected_href) {
-       free(job->selected_href);
-        job->selected_href = NULL;
-    }
+    free(job->selected_href);
+    job->selected_href = NULL;
 
     obj = job->selected_obj = job->current_obj;
     if (obj) {
index f09b711f454029f63c5726399f60644232a59225..a6ade5a4fe36c81f18094b7c5890d5007710f435 100644 (file)
@@ -118,8 +118,7 @@ void gv_argvlist_set_item(gv_argvlist_t *list, int index, char *item)
 
 void gv_argvlist_reset(gv_argvlist_t *list)
 {
-    if (list->argv)
-       free(list->argv);
+    free(list->argv);
     list->argv = NULL;
     list->alloc = 0;
     list->argc = 0;
@@ -127,8 +126,7 @@ void gv_argvlist_reset(gv_argvlist_t *list)
 
 void gv_argvlist_free(gv_argvlist_t *list)
 {
-    if (list->argv)
-       free(list->argv);
+    free(list->argv);
     free(list);
 }
 
@@ -141,10 +139,8 @@ void gvjobs_delete(GVC_t * gvc)
        job = job->next;
        gv_argvlist_reset(&(j->selected_obj_attributes));
        gv_argvlist_reset(&(j->selected_obj_type_name));
-       if (j->active_tooltip)
-           free(j->active_tooltip);
-       if (j->selected_href)
-           free(j->selected_href);
+       free(j->active_tooltip);
+       free(j->selected_href);
        free(j);
     }
     gvc->jobs = gvc->job = gvc->active_jobs = output_filename_job = output_langname_job =
index 6734bc36c20470d10067fe3c1a3f212a3da5d787..c53c5397301da08b0413502c85381b6c7f0c5246 100644 (file)
@@ -764,7 +764,7 @@ SparseMatrix makeMatrix(Agraph_t* g, int dim, SparseMatrix *D)
     free(I);
     free(J);
     free(val);
-    if (valD) free (valD);
+    free (valD);
 
     return A;
 }
index aa0c334aeb959e4448846fde74f9b2f8c3e47402..1bdfab2ea10e4125e2b3c87c4ce2b3e40ba1c950 100644 (file)
@@ -897,10 +897,8 @@ v_data *UG_graph(double *x, double *y, int n, int accurate_computation)
 void freeGraph (v_data * graph)
 {
     if (graph != NULL) {
-       if (graph[0].edges != NULL)
-           free(graph[0].edges);
-       if (graph[0].ewgts != NULL)
-           free(graph[0].ewgts);
+       free(graph[0].edges);
+       free(graph[0].ewgts);
        free(graph);
     }
 }
@@ -908,17 +906,13 @@ void freeGraph (v_data * graph)
 void freeGraphData(vtx_data * graph)
 {
     if (graph != NULL) {
-       if (graph[0].edges != NULL)
-           free(graph[0].edges);
-       if (graph[0].ewgts != NULL)
-           free(graph[0].ewgts);
+       free(graph[0].edges);
+       free(graph[0].ewgts);
 #ifdef USE_STYLES
-       if (graph[0].styles != NULL)
-           free(graph[0].styles);
+       free(graph[0].styles);
 #endif
 #ifdef DIGCOLA
-       if (graph[0].edists != NULL)
-           free(graph[0].edists);
+       free(graph[0].edists);
 #endif
        free(graph);
     }
index e8fa818fbbe030439e55464ffa05449b5c3dcdbd..c13a28fe7404126ae9819cb34134e403fe8a180d 100644 (file)
@@ -91,7 +91,7 @@ static void mkHeap(heap * h, int size)
 
 static void freeHeap(heap * h)
 {
-    if (h->data) free(h->data);
+    free(h->data);
 }
 
 static void
index c993f480dca1de1cdd0b7e16e8b9586dc1af99ef..48b99ed8c7fc56ff41ca59beb054e0b1d93f4cc3 100644 (file)
@@ -73,11 +73,9 @@ int lu_decompose(double **a, int n)
     if (lu)
        free_array(lu);
     lu = new_array(n, n, 0.0);
-    if (ps)
-       free(ps);
+    free(ps);
     ps = N_NEW(n, int);
-    if (scales)
-       free(scales);
+    free(scales);
     scales = N_NEW(n, double);
 
     for (i = 0; i < n; i++) {  /* For each row */
index 24720b88e6524d7210647462167093196ae54aad..69c1e6407ec7e9bf853232bfe9b65679450baf0d 100644 (file)
@@ -1480,8 +1480,7 @@ void neato_layout(Agraph_t * g)
                pinfo.fixed = bp;
                pinfo.doSplines = 1;
                packGraphs(n_cc, cc, g, &pinfo);
-               if (bp)
-                   free(bp);
+               free(bp);
            }
            else {
                neatoLayout(g, g, layoutMode, model, &am);
index 39fc9edbf777bc8dfee9d3af94045adfeb5e537c..122119a55c777ccb0d97745ed858f49b1ab506d9 100644 (file)
@@ -1158,7 +1158,7 @@ attachOrthoEdges (Agraph_t* g, maze* mp, int n_edges, route* route_list, splineI
        rte = route_list[irte];
        npts = 1 + 3*rte.n;
        if (npts > splsz) {
-               if (ispline) free (ispline);
+               free (ispline);
                ispline = N_GNEW(npts, pointf);
                splsz = npts;
        }
index 2d8dcae085699e3e9a9078060767c0aab22b7d6c..dfb04c473bfeffd8e2eab27b09b513e9cb840c7a 100644 (file)
@@ -164,9 +164,7 @@ layout (Agraph_t* g, int depth)
 
        /* pack rectangles */
     pts = putRects (total, gs, &pinfo);
-    if (pinfo.vals) {
-       free (pinfo.vals);
-    }
+    free (pinfo.vals);
 
     rootbb.LL = pointfof(INT_MAX, INT_MAX);
     rootbb.UR = pointfof(-INT_MAX, -INT_MAX);
index 5a0c56ddb9c97d8061d28dd755e824156ce49b80..23a555059d1b31ab9e24469b9e8145f22de31591 100644 (file)
@@ -150,10 +150,8 @@ int Pobspath(vconfig_t * config, Ppoint_t p0, int poly0, Ppoint_t p1,
     printDad(dad, config->N + 1);
 #endif
 
-    if (ptvis0)
-       free(ptvis0);
-    if (ptvis1)
-       free(ptvis1);
+    free(ptvis0);
+    free(ptvis1);
 
     output_route->pn = opn;
     output_route->ps = ops;
index 41a356ca05e8146332b3034e73b0a7567dc0d6f1..0a429bd32dff16a47ce72f89fe7c7c281ccf0de8 100644 (file)
@@ -47,9 +47,7 @@ void PriorityQueue_delete(PriorityQueue q){
       free(q->buckets);
     }
 
-    if (q->where){
-      free(q->where);
-    }
+    free(q->where);
 
     free(q->gain);
     free(q);
index d8c2d0af0669d310b9de472e5fb642c07df352ab..0ba70e95a09c80bb7c4e0170d7d6eec539d97d5f 100644 (file)
@@ -108,10 +108,8 @@ int sfclose(Sfio_t * f)
     f->endb = f->endr = f->endw = f->next = f->data;
 
     /* zap any associated auxiliary buffer */
-    if (f->rsrv) {
-       free(f->rsrv);
-       f->rsrv = NIL(Sfrsrv_t *);
-    }
+    free(f->rsrv);
+    f->rsrv = NIL(Sfrsrv_t *);
 
     /* delete any associated sfpopen-data */
     if (f->proc)
@@ -133,7 +131,6 @@ int sfclose(Sfio_t * f)
     }
 
   done:
-    if (data)
-       free(data);
+    free(data);
     return rv;
 }
index a582320ee4efdd56e0a1400656d487fa986d32f3..23ff857f478f0ae253838616541d20ff3d7f1559 100644 (file)
@@ -212,8 +212,7 @@ int _sfpclose(Sfio_t * f)
        return -1;
     f->proc = NIL(Sfproc_t *);
 
-    if (p->rdata)
-       free(p->rdata);
+    free(p->rdata);
 
     if (p->pid < 0)
        status = 0;
@@ -254,8 +253,7 @@ static int _sfpmode(Sfio_t * f, int type)
     if (type == SF_WRITE) {    /* save unread data */
        p->ndata = f->endb - f->next;
        if (p->ndata > p->size) {
-           if (p->rdata)
-               free((char *) p->rdata);
+           free((char *) p->rdata);
            if ((p->rdata = malloc(p->ndata)))
                p->size = p->ndata;
            else {
index 217ea7b5390aa38481514f771c552a9c5d0ff643..c837a87ca85e673833e19064e98f984100ee4656 100644 (file)
@@ -957,10 +957,8 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
     }
 
   pop_fmt:
-    if (fp) {
-       free(fp);
-       fp = NIL(Fmtpos_t *);
-    }
+    free(fp);
+    fp = NIL(Fmtpos_t *);
     while ((fm = fmstk)) {     /* pop the format stack and continue */
        if (fm->eventf) {
            if (!form || !form[0])
@@ -984,8 +982,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
     }
 
   done:
-    if (fp)
-       free(fp);
+    free(fp);
     while ((fm = fmstk)) {
        if (fm->eventf)
            (*fm->eventf) (f, SF_FINAL, NIL(void *), fm->ft);
index 7707d184cb6094be99f93622f8637a68f59c2230..3145656222b9e76a6e0e6d241de40b4103fb3cce 100644 (file)
@@ -728,10 +728,8 @@ int sfvscanf(Sfio_t * f, const char *form, va_list args)
     }
 
   pop_fmt:
-    if (fp) {
-       free(fp);
-       fp = NIL(Fmtpos_t *);
-    }
+    free(fp);
+    fp = NIL(Fmtpos_t *);
     while ((fm = fmstk)) {     /* pop the format stack and continue */
        if (fm->eventf) {
            if (!form || !form[0])
@@ -755,8 +753,7 @@ int sfvscanf(Sfio_t * f, const char *form, va_list args)
     }
 
   done:
-    if (fp)
-       free(fp);
+    free(fp);
     while ((fm = fmstk)) {
        if (fm->eventf)
            (*fm->eventf) (f, SF_FINAL, NIL(void *), fm->ft);
index 0660e45c360145f2dff28aeefe4a0fbb8e07f6d9..165f097811a6ceea0e648d0526cba98f1b0f3a49 100644 (file)
@@ -271,8 +271,7 @@ static void gdgen_missingfont(char *err, char *fontreq)
        agerr(AGERR, "%s : %s in %s\n", err, fontreq, p);
 #endif
 #endif
-       if (lastmissing)
-           free(lastmissing);
+       free(lastmissing);
        lastmissing = strdup(fontreq);
        n_errors++;
 #if 0
index 1e0cc20a0909554322710cad60182a5792607e84..9a8fb7f2e402a7c7c47b164fb993688c03ea3bcd 100644 (file)
@@ -238,8 +238,7 @@ static char *buildBindings(char *s1, char *s2)
            }
        }
     } else {
-       if (s1)
-           free(s1);
+       free(s1);
        l = strlen(s2);
        if (l) {
            s3 = malloc(l + 2);