From: Ben Pfaff Date: Thu, 28 Jan 2010 21:11:39 +0000 (-0800) Subject: dynamic-string: New function ds_swap(). X-Git-Tag: v1.0.0~259^2~225 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e83fd213300e19ad1da4e1ddbc049d4b858d34e8;p=sliver-openvswitch.git dynamic-string: New function ds_swap(). --- diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 7f5e3fbaa..c3338180d 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -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 diff --git a/lib/dynamic-string.h b/lib/dynamic-string.h index dc81fb3a7..eebbdbfe8 100644 --- a/lib/dynamic-string.h +++ b/lib/dynamic-string.h @@ -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);