X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcase.h;h=05c4568c6befe3f501cfcf65dd622ab10ee6023c;hb=2153ca9b3cb9616c616a4b58abb300de1f317541;hp=6f6abeb50938a67f10c710a3d38ddeea59669c5d;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp diff --git a/src/data/case.h b/src/data/case.h index 6f6abeb509..05c4568c6b 100644 --- a/src/data/case.h +++ b/src/data/case.h @@ -30,7 +30,7 @@ struct ccase { struct case_data *case_data; /* Actual data. */ -#if GLOBAL_DEBUGGING +#if DEBUGGING struct ccase *this; /* Detects unauthorized move/copy. */ #endif }; @@ -43,7 +43,7 @@ struct case_data union value values[1]; /* Values. */ }; -#ifdef GLOBAL_DEBUGGING +#ifdef DEBUGGING #define CASE_INLINE #else #define CASE_INLINE static @@ -89,9 +89,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 +115,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 +135,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 +188,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 */