Author: sandervanderburg Date: Fri Feb 10 23:11:04 2012 New Revision: 32224 URL: https://nixos.org/websvn/nix/?rev=32224&sc=1
Log: Some NULL checks to prevent errors Modified: disnix/dydisnix/trunk/src/graphcol/graphcol.c Modified: disnix/dydisnix/trunk/src/graphcol/graphcol.c ============================================================================== --- disnix/dydisnix/trunk/src/graphcol/graphcol.c Fri Feb 10 22:23:33 2012 (r32223) +++ disnix/dydisnix/trunk/src/graphcol/graphcol.c Fri Feb 10 23:11:04 2012 (r32224) @@ -53,13 +53,13 @@ vertex_adjacency->service = current_service->name; vertex_adjacency->adjacentServices = g_array_new(FALSE, FALSE, sizeof(gchar*)); - if(dependsOn != NULL) + if(dependsOn != NULL && dependsOn->value != NULL) { unsigned int j; gchar **dependencies = g_strsplit(dependsOn->value, " ", 0); for(j = 0; j < g_strv_length(dependencies) - 1; j++) - g_array_append_val(vertex_adjacency->adjacentServices, dependencies[j]); + g_array_append_val(vertex_adjacency->adjacentServices, dependencies[j]); g_free(dependencies); } @@ -75,7 +75,7 @@ Service *current_service = g_array_index(service_property_array, Service*, i); ServiceProperty *dependsOn = lookup_service_property(current_service, "dependsOn"); - if(dependsOn != NULL) + if(dependsOn != NULL && dependsOn->value != NULL) { unsigned int j; gchar **dependencies = g_strsplit(dependsOn->value, " ", 0); @@ -202,7 +202,11 @@ for(i = 0; i < adjacency_array->len; i++) { VertexAdjacency *current_adjacency = g_array_index(adjacency_array, VertexAdjacency*, i); - g_print(" %s = [ \"%s\" ];\n", current_adjacency->service, current_adjacency->target); + + if(current_adjacency->target == NULL) + g_print(" %s = [];\n", current_adjacency->service); + else + g_print(" %s = [ \"%s\" ];\n", current_adjacency->service, current_adjacency->target); } g_print("}\n"); _______________________________________________ nix-commits mailing list nix-comm...@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-commits