Changed a lot of ints to bools.
[pspp-builds.git] / src / data / case.h
index 6f6abeb50938a67f10c710a3d38ddeea59669c5d..df2f03560f3205106e4e60c7daa0d76e31b9c698 100644 (file)
@@ -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 <stdlib.h>
-#include "str.h"
+#include <libpspp/str.h>
 
 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 */