From: Ben Pfaff Date: Tue, 22 Dec 2009 01:11:47 +0000 (-0800) Subject: casereader: Make parameter to casereader_count_cases const. X-Git-Tag: fc11-x64-build67^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=302bd0da45b8920bf4a34d8751d9cbceacd5b6ea;p=pspp-builds.git casereader: Make parameter to casereader_count_cases const. casereader_count_cases does not conceptually modify its argument, since there is no way for the client to observe the difference (other than through improved performance). So there is no need for the parameter to be const. --- diff --git a/src/data/casereader.c b/src/data/casereader.c index 57afff84..97b7ceff 100644 --- a/src/data/casereader.c +++ b/src/data/casereader.c @@ -258,7 +258,8 @@ casereader_get_case_cnt (struct casereader *reader) } static casenumber -casereader_count_cases__ (struct casereader *reader, casenumber max_cases) +casereader_count_cases__ (const struct casereader *reader, + casenumber max_cases) { struct casereader *clone; casenumber n_cases; @@ -280,10 +281,13 @@ casereader_count_cases__ (struct casereader *reader, casenumber max_cases) of the contents of a clone of READER. Thus, the return value is always correct in the absence of I/O errors. */ casenumber -casereader_count_cases (struct casereader *reader) +casereader_count_cases (const struct casereader *reader) { if (reader->case_cnt == CASENUMBER_MAX) - reader->case_cnt = casereader_count_cases__ (reader, CASENUMBER_MAX); + { + struct casereader *reader_rw = CONST_CAST (struct casereader *, reader); + reader_rw->case_cnt = casereader_count_cases__ (reader, CASENUMBER_MAX); + } return reader->case_cnt; } diff --git a/src/data/casereader.h b/src/data/casereader.h index a78afaeb..f2231e2d 100644 --- a/src/data/casereader.h +++ b/src/data/casereader.h @@ -77,7 +77,7 @@ void casereader_force_error (struct casereader *); const struct taint *casereader_get_taint (const struct casereader *); casenumber casereader_get_case_cnt (struct casereader *); -casenumber casereader_count_cases (struct casereader *); +casenumber casereader_count_cases (const struct casereader *); void casereader_truncate (struct casereader *, casenumber); const struct caseproto *casereader_get_proto (const struct casereader *);