X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcase.h;h=c7d7e9fbbc108fdade4f3a6af1f88554ddbfdb24;hb=7dc203206d3f3172474a4ec0f4dcab5364f4ce26;hp=9e8b6e4fadcdfd3437087529886f4c4b781dbcc2;hpb=06f9ee45954e5e71fa7f6262dbf37defa1dbf996;p=pspp diff --git a/src/case.h b/src/case.h index 9e8b6e4fad..c7d7e9fbbc 100644 --- a/src/case.h +++ b/src/case.h @@ -28,18 +28,18 @@ case_move() or case_clone() instead of copying. */ struct ccase { - struct case_data *case_data; + struct case_data *case_data; /* Actual data. */ #if GLOBAL_DEBUGGING - struct ccase *this; + struct ccase *this; /* Detects unauthorized move/copy. */ #endif }; /* Invisible to user code. */ struct case_data { - size_t value_cnt; - unsigned ref_cnt; - union value values[1]; + size_t value_cnt; /* Number of values. */ + unsigned ref_cnt; /* Reference count. */ + union value values[1]; /* Values. */ }; #ifdef GLOBAL_DEBUGGING @@ -56,6 +56,9 @@ CASE_INLINE void case_clone (struct ccase *, const struct ccase *); CASE_INLINE void case_move (struct ccase *, struct ccase *); CASE_INLINE void case_destroy (struct ccase *); +void case_resize (struct ccase *, size_t old_cnt, size_t new_cnt); +void case_swap (struct ccase *, struct ccase *); + int case_try_create (struct ccase *, size_t value_cnt); int case_try_clone (struct ccase *, const struct ccase *); @@ -63,9 +66,9 @@ CASE_INLINE void case_copy (struct ccase *dst, size_t dst_idx, const struct ccase *src, size_t src_idx, size_t cnt); -CASE_INLINE size_t case_serial_size (size_t value_cnt); -CASE_INLINE void case_serialize (const struct ccase *, void *, size_t); -CASE_INLINE void case_unserialize (struct ccase *, const void *, size_t); +CASE_INLINE void case_to_values (const struct ccase *, union value *, size_t); +CASE_INLINE void case_from_values (struct ccase *, + const union value *, size_t); CASE_INLINE const union value *case_data (const struct ccase *, size_t idx); CASE_INLINE double case_num (const struct ccase *, size_t idx); @@ -73,6 +76,9 @@ CASE_INLINE const char *case_str (const struct ccase *, size_t idx); CASE_INLINE union value *case_data_rw (struct ccase *, size_t idx); +const union value *case_data_all (const struct ccase *); +union value *case_data_all_rw (struct ccase *); + void case_unshare (struct ccase *); #ifndef GLOBAL_DEBUGGING @@ -126,28 +132,22 @@ case_copy (struct ccase *dst, size_t dst_idx, sizeof *dst->case_data->values * value_cnt); } -static inline size_t -case_serial_size (size_t value_cnt) -{ - return value_cnt * sizeof (union value); -} - static inline void -case_serialize (const struct ccase *c, void *output, - size_t output_size UNUSED) +case_to_values (const struct ccase *c, union value *output, + size_t output_size ) { memcpy (output, c->case_data->values, - case_serial_size (c->case_data->value_cnt)); + output_size * sizeof *output); } static inline void -case_unserialize (struct ccase *c, const void *input, +case_from_values (struct ccase *c, const union value *input, size_t input_size UNUSED) { if (c->case_data->ref_cnt > 1) case_unshare (c); memcpy (c->case_data->values, input, - case_serial_size (c->case_data->value_cnt)); + c->case_data->value_cnt * sizeof *input); } static inline const union value *