dynamic-string: New function ds_swap().
authorBen Pfaff <blp@nicira.com>
Thu, 28 Jan 2010 21:11:39 +0000 (13:11 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 29 Jan 2010 00:06:31 +0000 (16:06 -0800)
lib/dynamic-string.c
lib/dynamic-string.h

index 7f5e3fb..c333818 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -242,6 +242,15 @@ ds_destroy(struct ds *ds)
     free(ds->string);
 }
 
+/* Swaps the content of 'a' and 'b'. */
+void
+ds_swap(struct ds *a, struct ds *b)
+{
+    struct ds temp = *a;
+    *a = *b;
+    *b = temp;
+}
+
 /* Writes the 'size' bytes in 'buf' to 'string' as hex bytes arranged 16 per
  * line.  Numeric offsets are also included, starting at 'ofs' for the first
  * byte in 'buf'.  If 'ascii' is true then the corresponding ASCII characters
index dc81fb3..eebbdbf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,7 @@ char *ds_cstr(struct ds *);
 const char *ds_cstr_ro(const struct ds *);
 char *ds_steal_cstr(struct ds *);
 void ds_destroy(struct ds *);
+void ds_swap(struct ds *, struct ds *);
 
 int ds_last(const struct ds *);
 void ds_chomp(struct ds *, int c);