X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcase-tmpfile.c;h=0290f51126380366a233e8a3e5dc1f6eb8c22a68;hb=fb5ee794ece0f21f0b52ee41e66a8b79c159bcf2;hp=2b47d6dd26de83831cafba2bf0e15e8b3d63fc76;hpb=70514b3f2f32d57e58b04c01c83bc5f372559824;p=pspp diff --git a/src/data/case-tmpfile.c b/src/data/case-tmpfile.c index 2b47d6dd26..0290f51126 100644 --- a/src/data/case-tmpfile.c +++ b/src/data/case-tmpfile.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010, 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,18 +16,17 @@ #include -#include +#include "data/case-tmpfile.h" #include #include #include -#include -#include -#include +#include "libpspp/assertion.h" +#include "libpspp/taint.h" +#include "libpspp/ext-array.h" -#include "error.h" -#include "xalloc.h" +#include "gl/xalloc.h" /* A temporary file that stores an array of cases. */ struct case_tmpfile @@ -36,7 +35,7 @@ struct case_tmpfile struct caseproto *proto; /* Format of cases in the tmpfile. */ size_t case_size; /* Number of bytes per case. */ size_t *offsets; /* Offset to each value. */ - struct temp_file *temp_file; /* Temporary file. */ + struct ext_array *ext_array; /* Temporary file. */ }; /* Returns the number of bytes needed to store a value with the @@ -52,12 +51,12 @@ width_to_n_bytes (int width) static void * value_to_data (const union value *value_, int width) { - union value *value = (union value *) value_; + union value *value = CONST_CAST (union value *, value_); assert (sizeof value->f == sizeof (double)); if (width == 0) return &value->f; else - return value_str_rw (value, width); + return value->s; } /* Creates and returns a new case_tmpfile that will store cases @@ -72,7 +71,7 @@ case_tmpfile_create (const struct caseproto *proto) ctf = xmalloc (sizeof *ctf); ctf->taint = taint_create (); - ctf->temp_file = temp_file_create (); + ctf->ext_array = ext_array_create (); ctf->proto = caseproto_ref (proto); ctf->case_size = 0; n_values = caseproto_get_n_widths (proto); @@ -97,7 +96,7 @@ case_tmpfile_destroy (struct case_tmpfile *ctf) if (ctf != NULL) { struct taint *taint = ctf->taint; - temp_file_destroy (ctf->temp_file); + ext_array_destroy (ctf->ext_array); caseproto_unref (ctf->proto); free (ctf->offsets); free (ctf); @@ -149,7 +148,7 @@ case_tmpfile_get_values (const struct case_tmpfile *ctf, { int width = caseproto_get_width (ctf->proto, i); if (width != -1 - && !temp_file_read (ctf->temp_file, case_offset + ctf->offsets[i], + && !ext_array_read (ctf->ext_array, case_offset + ctf->offsets[i], width_to_n_bytes (width), value_to_data (&values[i], width))) return false; @@ -194,7 +193,7 @@ case_tmpfile_put_values (struct case_tmpfile *ctf, { int width = caseproto_get_width (ctf->proto, i); if (width != -1 - && !temp_file_write (ctf->temp_file, case_offset + ctf->offsets[i], + && !ext_array_write (ctf->ext_array, case_offset + ctf->offsets[i], width_to_n_bytes (width), value_to_data (values++, width))) return false;