X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcase.c;h=80478e7d72c36b426c2155e916d531a80df5f0a2;hb=d807ad29cc0d3caa4f0e04ee4b75c70a225cfeaf;hp=21fb0bdbfdb725a58cd73f5640e5ed8c5f9ebee7;hpb=d2ec80c72483254a876b0bb86882224248110c0c;p=pspp-builds.git diff --git a/src/case.c b/src/case.c index 21fb0bdb..80478e7d 100644 --- a/src/case.c +++ b/src/case.c @@ -152,6 +152,27 @@ case_destroy (struct ccase *c) } #endif /* GLOBAL_DEBUGGING */ +/* Resizes case C from OLD_CNT to NEW_CNT values. */ +void +case_resize (struct ccase *c, size_t old_cnt, size_t new_cnt) +{ + struct ccase new; + + case_create (&new, new_cnt); + case_copy (&new, 0, c, 0, old_cnt < new_cnt ? old_cnt : new_cnt); + case_swap (&new, c); + case_destroy (&new); +} + +/* Swaps cases A and B. */ +void +case_swap (struct ccase *a, struct ccase *b) +{ + struct case_data *t = a->case_data; + a->case_data = b->case_data; + b->case_data = t; +} + /* Attempts to create C as a new case that holds VALUE_CNT values. Returns nonzero if successful, zero if memory allocation failed. */