cleanup
[pspp] / src / data / caseproto.h
index e6921888f58baf7e12332810f241f2ac0cc60b42..8af1b0b4919e18af6df9ed834990ed2422ddef4d 100644 (file)
    A case prototype specifies the number and type of the values
    in a case.  It is essentially an array of integers, where the
    array index is an index into a case and each element
-   represents the width of a value in a case.  Valid widths are:
-
-       * 0, indicating a numeric value.
-
-       * A positive integer between 1 and 32767, indicating the
-         size in bytes of a string value.
-
-       * -1, indicating that the value at this index in the case
-         is not used at all.  (This is rarely useful.)
+   represents the width of a value in a case.  A width of 0
+   indicates a numeric value, and any positive integer up to
+   MAX_STRING indicate the size in bytes of a string value.
 
    Case prototypes are reference counted.  A newly created case
    prototype has a single owner (the code that created it),
@@ -51,9 +45,7 @@
    piece of code that incremented the reference count.
 
    Functions that modifying case prototypes automatically unshare
-   them as necessary.  All of these functions potentially move
-   the caseproto around in memory even when the case prototype is
-   not shared.  Thus it is very important that every caller of a
+   them as necessary.  Thus it is very important that every caller of a
    function that modifies a case prototype thereafter uses the returned
    caseproto instead of the one passed in as an argument.
 
@@ -72,13 +64,14 @@ struct caseproto
     /* Widths. */
     size_t n_widths;            /* Number of widths. */
     size_t allocated_widths;    /* Space allocated for 'widths' array. */
-    short int widths[1];        /* Width of each case value. */
+    short int *widths;          /* Width of each case value. */
   };
 
 struct pool;
 
 /* Creation and destruction. */
 struct caseproto *caseproto_create (void) MALLOC_LIKE;
+struct caseproto *caseproto_from_widths (short int *, size_t n) MALLOC_LIKE;
 static inline struct caseproto *caseproto_ref (const struct caseproto *) WARN_UNUSED_RESULT;
 struct caseproto *caseproto_ref_pool (const struct caseproto *, struct pool *) WARN_UNUSED_RESULT;
 static inline void caseproto_unref (struct caseproto *);
@@ -130,9 +123,10 @@ bool caseproto_range_is_valid (const struct caseproto *,
                                size_t ofs, size_t count);
 bool caseproto_is_conformable (const struct caseproto *a,
                                const struct caseproto *b);
-bool caseproto_equal (const struct caseproto *a, size_t a_start,
-                      const struct caseproto *b, size_t b_start,
-                      size_t n);
+bool caseproto_range_equal (const struct caseproto *a, size_t a_start,
+                            const struct caseproto *b, size_t b_start,
+                            size_t n);
+bool caseproto_equal (const struct caseproto *, const struct caseproto *);
 \f
 /* Creation and destruction. */