str: New function ss_swap().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 18 Jul 2021 21:20:06 +0000 (14:20 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 18 Jul 2021 21:20:11 +0000 (14:20 -0700)
src/libpspp/str.c
src/libpspp/str.h

index 99602fba681e699146f2ddb4922b2e90ac1caadc..86e7fd9199a5b9e22fba9fa2ac2eec4e9e7ff1c7 100644 (file)
@@ -425,6 +425,15 @@ ss_dealloc (struct substring *ss)
   free (ss->string);
 }
 
+/* Exchanges the contents of A and B. */
+void
+ss_swap (struct substring *a, struct substring *b)
+{
+  struct substring tmp = *a;
+  *a = *b;
+  *b = tmp;
+}
+
 /* Truncates SS to at most CNT bytes in length. */
 void
 ss_truncate (struct substring *ss, size_t cnt)
index 57783e0ea57a7615aa31315f07160d91be978caf..8cde5779143773e5dd3aeb02d914a01a4740ae16 100644 (file)
@@ -103,6 +103,7 @@ void ss_dealloc (struct substring *);
 /* Mutators.
    Functions that advance the beginning of a string should not be
    used if a substring is to be deallocated. */
+void ss_swap (struct substring *, struct substring *);
 void ss_truncate (struct substring *, size_t);
 size_t ss_rtrim (struct substring *, struct substring trim_set);
 size_t ss_ltrim (struct substring *, struct substring trim_set);