X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Ftaint.c;h=08bdb6a799bb28729b7b68b8003fce8ead75976a;hb=f42cd385428298f9ee9795a3296e32363a9b0baa;hp=4c1cecb97cdbbdbcdd2302e91f2741e7a68a8bc2;hpb=7c08a6e1009cf60847e770a77a73c650e9326379;p=pspp diff --git a/src/libpspp/taint.c b/src/libpspp/taint.c index 4c1cecb97c..08bdb6a799 100644 --- a/src/libpspp/taint.c +++ b/src/libpspp/taint.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,15 +16,15 @@ #include -#include +#include "libpspp/taint.h" #include -#include -#include -#include +#include "libpspp/array.h" +#include "libpspp/assertion.h" +#include "libpspp/cast.h" -#include "xalloc.h" +#include "gl/xalloc.h" /* This code maintains two invariants: @@ -37,7 +37,7 @@ /* A list of pointers to taint structures. */ struct taint_list { - size_t cnt; + size_t n; struct taint **taints; }; @@ -96,21 +96,21 @@ taint_clone (const struct taint *taint_) bool taint_destroy (struct taint *taint) { - if ( taint ) + if (taint) { bool was_tainted = taint_is_tainted (taint); if (--taint->ref_cnt == 0) { size_t i, j; - for (i = 0; i < taint->predecessors.cnt; i++) - for (j = 0; j < taint->successors.cnt; j++) + for (i = 0; i < taint->predecessors.n; i++) + for (j = 0; j < taint->successors.n; j++) taint_propagate (taint->predecessors.taints[i], taint->successors.taints[j]); - for (i = 0; i < taint->predecessors.cnt; i++) + for (i = 0; i < taint->predecessors.n; i++) taint_list_remove (&taint->predecessors.taints[i]->successors, taint); - for (i = 0; i < taint->successors.cnt; i++) + for (i = 0; i < taint->successors.n; i++) taint_list_remove (&taint->successors.taints[i]->predecessors, taint); taint_list_destroy (&taint->successors); @@ -193,7 +193,7 @@ taint_reset_successor_taint (const struct taint *taint_) { size_t i; - for (i = 0; i < taint->successors.cnt; i++) + for (i = 0; i < taint->successors.n; i++) if (taint->successors.taints[i]->tainted_successor) return; @@ -205,7 +205,7 @@ taint_reset_successor_taint (const struct taint *taint_) static void taint_list_init (struct taint_list *list) { - list->cnt = 0; + list->n = 0; list->taints = NULL; } @@ -222,7 +222,7 @@ taint_list_contains (const struct taint_list *list, const struct taint *taint) { size_t i; - for (i = 0; i < list->cnt; i++) + for (i = 0; i < list->n; i++) if (list->taints[i] == taint) return true; @@ -247,11 +247,11 @@ taint_list_add (struct taint_list *list, struct taint *taint) list capacity is always zero or a power of 2. Thus, if the list count is one of these threshold values, we need to allocate more memory. */ - if (is_zero_or_power_of_2 (list->cnt)) + if (is_zero_or_power_of_2 (list->n)) list->taints = xnrealloc (list->taints, - list->cnt == 0 ? 1 : 2 * list->cnt, + list->n == 0 ? 1 : 2 * list->n, sizeof *list->taints); - list->taints[list->cnt++] = taint; + list->taints[list->n++] = taint; } } @@ -261,11 +261,11 @@ taint_list_remove (struct taint_list *list, const struct taint *taint) { size_t i; - for (i = 0; i < list->cnt; i++) + for (i = 0; i < list->n; i++) if (list->taints[i] == taint) { - remove_element (list->taints, list->cnt, sizeof *list->taints, i); - list->cnt--; + remove_element (list->taints, list->n, sizeof *list->taints, i); + list->n--; return; } @@ -281,13 +281,13 @@ recursively_set_taint (struct taint *taint) size_t i; taint->tainted = taint->tainted_successor = true; - for (i = 0; i < taint->successors.cnt; i++) + for (i = 0; i < taint->successors.n; i++) { struct taint *s = taint->successors.taints[i]; if (!s->tainted) recursively_set_taint (s); } - for (i = 0; i < taint->predecessors.cnt; i++) + for (i = 0; i < taint->predecessors.n; i++) { struct taint *p = taint->predecessors.taints[i]; if (!p->tainted_successor) @@ -303,7 +303,7 @@ recursively_set_tainted_successor (struct taint *taint) size_t i; taint->tainted_successor = true; - for (i = 0; i < taint->predecessors.cnt; i++) + for (i = 0; i < taint->predecessors.n; i++) { struct taint *p = taint->predecessors.taints[i]; if (!p->tainted_successor)