struct ccase
{
struct case_data *case_data; /* Actual data. */
-#if DEBUGGING
- struct ccase *this; /* Detects unauthorized move/copy. */
-#endif
};
/* Invisible to user code. */
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,
#ifndef DEBUGGING
#include <stdlib.h>
-#include "str.h"
+#include <libpspp/str.h>
static inline void
case_nullify (struct ccase *c)
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
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