Index: libabac/abac_graph.c
===================================================================
--- libabac/abac_graph.c	(revision 4571abc006df24cb0c1c70751ac5374770075908)
+++ libabac/abac_graph.c	(revision fc1a6b4c44a1676245861fa3bf215caaaf10ee1e)
@@ -1,2 +1,5 @@
+
+/* abac_graph.c */
+
 #include <assert.h>
 #include <stdlib.h>
@@ -54,4 +57,5 @@
 
 static abac_vertex_t *_dup_vertex(abac_vertex_t *v);
+int abac_graph_add_credential(abac_graph_t *graph, abac_credential_t *cred);
 
 /**
@@ -119,4 +123,5 @@
             abac_list_foreach(abac_role_prereqs(role), prereq,
                 abac_vertex_t *tail_vertex = _get_vertex(graph, prereq);
+/*??? */
                 abac_list_add(vertex->prereqs, _dup_vertex(tail_vertex));
             );
@@ -131,7 +136,6 @@
 
         } else {
-/* ??? */
-            return vertex;
-
+          return vertex;
+/* ??? return _dup_vertex(vertex); */ 
     }
 
@@ -141,4 +145,5 @@
 /* forward decl */
 static void _free_edge(abac_edge_t *edge);
+
 /*
  * Reduce the vertex reference count and free it if this is the last reference
@@ -149,4 +154,5 @@
 
     --vertex->refcount;
+
     if ( vertex->refcount > 0) return;
 
@@ -245,6 +251,8 @@
     abac_list_foreach(head_vertex->edges, edge,
         if (edge->vertex == tail_vertex) {
+/*
             _free_vertex(head_vertex);
             _free_vertex(tail_vertex);
+*/
             return 0;
         }
@@ -296,6 +304,6 @@
         abac_list_remove(tail->reverse_vertex->edges, tail);
 
+        _free_edge(tail);
         free(current);
-        _free_edge(tail);
     }
 }
@@ -459,6 +467,7 @@
         return;
 
-    if (preorder)
+    if (preorder) {
         abac_list_add(stack, vertex);
+    }
 
     // recurse along the incoming vertices
@@ -467,6 +476,7 @@
     );
 
-    if (!preorder)
+    if (!preorder) {
         abac_list_add(stack, vertex);
+    }
 }
 
@@ -474,5 +484,7 @@
     debug_printf("%sorder at %s\n", preorder ? "pre" : "post", abac_role_string(start));
 
+
     abac_vertex_t *start_vertex = _get_vertex(graph, start);
+
     abac_set_t *seen = abac_set_new();
 
@@ -483,4 +495,5 @@
 
     abac_set_free(seen);
+
 
     return stack;
@@ -494,6 +507,7 @@
         return;
 
-    if (preorder)
+    if (preorder) {
         abac_list_add(stack, vertex);
+    }
 
     // recurse along the incoming vertices
@@ -502,6 +516,7 @@
     );
 
-    if (!preorder)
+    if (!preorder) {
         abac_list_add(stack, vertex);
+    }
 }
 
@@ -510,4 +525,5 @@
 
     abac_vertex_t *start_vertex = _get_vertex(graph, start);
+
     abac_set_t *seen = abac_set_new();
 
@@ -541,6 +557,8 @@
     abac_list_foreach(order, vertex,
         abac_list_foreach(vertex->edges, incoming,
-            if (incoming->credential != NULL)
+            if (incoming->credential != NULL) {
+/* ??? do we need to duplicate this?? */
                 abac_list_add(credentials, abac_credential_dup(incoming->credential));
+            }
         );
     );
@@ -570,8 +588,10 @@
     // go through the list and dup all the credentials
     abac_list_t *credentials = abac_list_new();
+
     abac_list_foreach(order, vertex,
         abac_list_foreach(vertex->reverse_edges, outgoing,
-            if (outgoing->credential != NULL)
+            if (outgoing->credential != NULL) {
                 abac_list_add(credentials, abac_credential_dup(outgoing->credential));
+            }
         );
     );
@@ -586,5 +606,4 @@
     abac_vertex_t *vertex;
     abac_edge_t *incoming;
-
     abac_role_t *role = abac_role_from_string(role_name);
     abac_role_t *prin_role = abac_role_from_string(principal);
@@ -652,6 +671,8 @@
     abac_graph_derive_links(graph);
     abac_graph_t *result_graph = abac_graph_new();
+
     abac_list_t *result = abac_graph_postorder_reverse_credentials(graph, 
 	    principal);
+
     abac_credential_t *cur = NULL;
     abac_list_foreach(result, cur,
@@ -661,4 +682,5 @@
     /* For each terminal role that the principal can reach, roll a proof into
        the result_graph. */
+
     abac_vertex_t *vertex = NULL;
     for (vertex = result_graph->vertices; vertex != NULL; 
@@ -668,4 +690,5 @@
     }
     abac_graph_derive_links(result_graph);
+
     return result_graph;
 }
