Added checks for null pointer allocation.
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Sun, 1 Aug 1999 13:11:56 +0000 (13:11 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Sun, 1 Aug 1999 13:11:56 +0000 (13:11 +0000)
src/conv-ldb/edgelist.c
src/conv-ldb/generate.c
src/conv-ldb/typedefs.h

index 3e3fd0a65347f909a3355bef55179f62ce98aa3c..96309cb25f36ec851330deef10067041cd553f28 100644 (file)
@@ -10,8 +10,10 @@ int E;
   EdgeListType * edgesRec;
 
   edgesRec = (EdgeListType *) malloc(sizeof(EdgeListType));
+  _MEMCHECK(edgesRec);
   edgesRec->next = 0;
   edgesRec->edges = (Edge *) malloc(E*sizeof(Edge));
+  _MEMCHECK(edgesRec->edges);
   return(edgesRec);
 }
 
index 22d497608f2031c254b76762cead4ed8a63c51c8..3c2c31bcdaa1ff2db0f00868d9bb7441afbbea8c 100644 (file)
@@ -115,10 +115,13 @@ InitVertices(EdgeList, V,E)
   VerticesListType * vlist;
 
   vlist = (VerticesListType *) malloc(sizeof(VerticesListType));
+  _MEMCHECK(vlist);
   vlist->numVertices = V;
   vlist->vertexArray = (Vertex *) malloc(V*sizeof(Vertex));
+  _MEMCHECK(vlist->vertexArray);
   vlist->adjArray = (int *) malloc(2*E*sizeof(int)); 
                     /* as each edge is entered twice */
+  _MEMCHECK(vlist->adjArray);
   countDegrees(EdgeList->edges, vlist->vertexArray, V, E);
   fillAdjArray(EdgeList->edges, vlist, V, E);
   sortAdjArrays(vlist);
@@ -263,7 +266,9 @@ initGraph()
 { int i;
   graph.numVertices = V;
   graph.vertexArray = (Vertex *) malloc(V*sizeof(Vertex));
+  _MEMCHECK(graph.vertexArray);
   graph.adjArray = (int *) malloc(2*E*sizeof(int));
+  _MEMCHECK(graph.adjArray);
 
   for (i=0; i< V; i++) {
     graph.vertexArray[i].degree = 0;
@@ -328,10 +333,12 @@ diameter()
 Q * makeQueue()
 {
   Q *q = (Q *) malloc(sizeof(Q));
+  _MEMCHECK(q);
   q->size = VMAX;
   q->head = 1;
   q->tail = 0;
   q->buf = (int *) malloc(VMAX*sizeof(int));
+  _MEMCHECK(q->buf);
   return q;
 }
 
index 6c40968f9741927cf5574929607294a655e8022f..4857bbf35362102d971fafbdbc930f76d4746727 100644 (file)
@@ -1,3 +1,5 @@
+#include "converse.h"
+
 typedef struct {int node1, node2;} Edge;
 
 typedef struct {int next;