+2007-06-03  Ben Pfaff  <blp@gnu.org>
+
+       Slightly generalize case_to_values and case_from_values functions.
+
+       * case.c (case_to_values): Rename case_copy_out, change interface.
+       (case_from_values): Rename case_copy_in, change interface.
+
+       * fastfile.c (fastfilereader_get_next_case): Update caller.
+       (write_case_to_disk): Ditto.
+
 2007-06-02  Ben Pfaff  <blp@gnu.org>
 
        Clean up after a forgotten part of patch #5829.
 
     }
 }
 
-/* Copies case C to OUTPUT.
-   OUTPUT_SIZE is the number of `union values' in OUTPUT,
-   which must match the number of `union values' in C. */
+/* Copies VALUE_CNT values out of case C to VALUES, starting at
+   the given START_IDX. */
 void
-case_to_values (const struct ccase *c, union value *output,
-                size_t output_size UNUSED) 
+case_copy_out (const struct ccase *c,
+               size_t start_idx, union value *values, size_t value_cnt) 
 {
   assert (c->case_data->ref_cnt > 0);
-  assert (output_size == c->case_data->value_cnt);
-  assert (output != NULL || output_size == 0);
+  assert (value_cnt <= c->case_data->value_cnt);
+  assert (start_idx + value_cnt <= c->case_data->value_cnt);
 
-  memcpy (output, c->case_data->values,
-          c->case_data->value_cnt * sizeof *output);
+  memcpy (values, c->case_data->values + start_idx,
+          value_cnt * sizeof *values);
 }
 
-/* Copies INPUT into case C.
-   INPUT_SIZE is the number of `union values' in INPUT,
-   which must match the number of `union values' in C. */
+/* Copies VALUE_CNT values from VALUES into case C, staring at
+   the given START_IDX. */
 void
-case_from_values (struct ccase *c, const union value *input,
-                  size_t input_size UNUSED) 
+case_copy_in (struct ccase *c,
+              size_t start_idx, const union value *values, size_t value_cnt) 
 {
   assert (c->case_data->ref_cnt > 0);
-  assert (input_size == c->case_data->value_cnt);
-  assert (input != NULL || input_size == 0);
+  assert (value_cnt <= c->case_data->value_cnt);
+  assert (start_idx + value_cnt <= c->case_data->value_cnt);
 
   case_unshare (c);
-  memcpy (c->case_data->values, input,
-          c->case_data->value_cnt * sizeof *input);
+  memcpy (c->case_data->values + start_idx, values,
+          value_cnt * sizeof *values);
 }
 
 /* Returns a pointer to the `union value' used for the
 
 bool case_try_clone (struct ccase *, const struct ccase *);
 
 void case_copy (struct ccase *dst, size_t dst_idx,
-                            const struct ccase *src, size_t src_idx,
-                            size_t cnt);
+                const struct ccase *src, size_t src_idx,
+                size_t cnt);
 
-void case_to_values (const struct ccase *, union value *, size_t);
-void case_from_values (struct ccase *,
-                                   const union value *, size_t);
+void case_copy_out (const struct ccase *,
+                       size_t start_idx, union value *, size_t value_cnt);
+void case_copy_in (struct ccase *,
+                       size_t start_idx, const union value *, size_t value_cnt);
 
 const union value *case_data (const struct ccase *, const struct variable *);
 double case_num (const struct ccase *, const struct variable *);
 
          ffr->buffer_pos = 0;
        }
 
-      case_from_values (&ffr->c, ffr->buffer + ffr->buffer_pos,
-                       ff->value_cnt);
+      case_copy_in (&ffr->c, 0, ffr->buffer + ffr->buffer_pos, ff->value_cnt);
       ffr->buffer_pos += ff->value_cnt;
       
       read_case = &ffr->c;
   if (!ff->ok)
     return;
 
-  case_to_values (c, ff->buffer + ff->buffer_used, ff->value_cnt);
+  case_copy_out (c, 0, ff->buffer + ff->buffer_used, ff->value_cnt);
   ff->buffer_used += ff->value_cnt;
   if (ff->buffer_used + ff->value_cnt > ff->buffer_size)
     flush_buffer (ff);