X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcase.h;h=df2f03560f3205106e4e60c7daa0d76e31b9c698;hb=19d0debdc5b72e1bb6c79956403a4d3bc054f300;hp=6f6abeb50938a67f10c710a3d38ddeea59669c5d;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp-builds.git diff --git a/src/data/case.h b/src/data/case.h index 6f6abeb5..df2f0356 100644 --- a/src/data/case.h +++ b/src/data/case.h @@ -30,9 +30,6 @@ struct ccase { struct case_data *case_data; /* Actual data. */ -#if GLOBAL_DEBUGGING - struct ccase *this; /* Detects unauthorized move/copy. */ -#endif }; /* Invisible to user code. */ @@ -43,7 +40,7 @@ struct case_data union value values[1]; /* Values. */ }; -#ifdef GLOBAL_DEBUGGING +#ifdef DEBUGGING #define CASE_INLINE #else #define CASE_INLINE static @@ -60,8 +57,8 @@ 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 *); +bool case_try_create (struct ccase *, size_t value_cnt); +bool case_try_clone (struct ccase *, const struct ccase *); CASE_INLINE void case_copy (struct ccase *dst, size_t dst_idx, const struct ccase *src, size_t src_idx, @@ -89,9 +86,9 @@ union value *case_data_all_rw (struct ccase *); void case_unshare (struct ccase *); -#ifndef GLOBAL_DEBUGGING +#ifndef DEBUGGING #include -#include "str.h" +#include static inline void case_nullify (struct ccase *c) @@ -115,8 +112,11 @@ case_clone (struct ccase *clone, const struct ccase *orig) static inline void case_move (struct ccase *dst, struct ccase *src) { - *dst = *src; - src->case_data = NULL; + if (dst != src) + { + *dst = *src; + src->case_data = NULL; + } } static inline void @@ -132,12 +132,14 @@ case_copy (struct ccase *dst, size_t dst_idx, const struct ccase *src, size_t src_idx, size_t value_cnt) { - if (dst->case_data->ref_cnt > 1) - case_unshare (dst); if (dst->case_data != src->case_data || dst_idx != src_idx) - memmove (dst->case_data->values + dst_idx, - src->case_data->values + src_idx, - sizeof *dst->case_data->values * value_cnt); + { + if (dst->case_data->ref_cnt > 1) + case_unshare (dst); + memmove (dst->case_data->values + dst_idx, + src->case_data->values + src_idx, + sizeof *dst->case_data->values * value_cnt); + } } static inline void @@ -183,6 +185,6 @@ case_data_rw (struct ccase *c, size_t idx) case_unshare (c); return &c->case_data->values[idx]; } -#endif /* !GLOBAL_DEBUGGING */ +#endif /* !DEBUGGING */ #endif /* case.h */