X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdictionary.c;h=758f199763facd24f20513520bc934508c86d457;hb=f62700038e9edd7d8002242015a900a15626bceb;hp=3f1177d35f4f3f54ca827c47a68d659b4c012fe3;hpb=933b760efccdfa26f14254f1fae002ea3b0a1495;p=pspp diff --git a/src/dictionary.c b/src/dictionary.c index 3f1177d35f..758f199763 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -223,7 +223,7 @@ dict_get_var (const struct dictionary *d, size_t idx) exclude ordinary, system, and/or scratch variables. */ void dict_get_vars (const struct dictionary *d, struct variable ***vars, - size_t *cnt, unsigned exclude_classes) + int *cnt, unsigned exclude_classes) { size_t count; size_t i; @@ -491,6 +491,23 @@ dict_delete_vars (struct dictionary *d, dict_delete_var (d, *vars++); } +/* Deletes scratch variables from dictionary D. */ +void +dict_delete_scratch_vars (struct dictionary *d) +{ + int i; + + /* FIXME: this can be done in O(count) time, but this algorithm + is O(count**2). */ + assert (d != NULL); + + for (i = 0; i < d->var_cnt; ) + if (dict_class_from_id (d->var[i]->name) == DC_SCRATCH) + dict_delete_var (d, d->var[i]); + else + i++; +} + /* Moves V to 0-based position IDX in D. Other variables in D, if any, retain their relative positions. Runs in time linear in the distance moved. */