X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fdynamic-string.c;h=180a4301c3fe218eb3b65e69713f006b70a217dc;hb=f4b6076acab233cfe02e7eaefdeafbb69dfae556;hp=527dee8ab09e288d62195f37e89414281bf2933e;hpb=1fd13cde12973420d573af8d161c612a9203b1cd;p=openvswitch diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 527dee8a..180a4301 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. @@ -66,7 +66,7 @@ ds_put_uninit(struct ds *ds, size_t n) } void -ds_put_char(struct ds *ds, char c) +ds_put_char__(struct ds *ds, char c) { *ds_put_uninit(ds, 1) = c; } @@ -179,7 +179,7 @@ void ds_put_strftime(struct ds *ds, const char *template, const struct tm *tm) { if (!tm) { - time_t now = time_now(); + time_t now = time_wall(); tm = localtime(&now); } for (;;) { @@ -219,6 +219,12 @@ ds_cstr(struct ds *ds) return ds->string; } +const char * +ds_cstr_ro(const struct ds *ds) +{ + return ds_cstr((struct ds *) ds); +} + /* Returns a null-terminated string representing the current contents of 'ds', * which the caller is expected to free with free(), then clears the contents * of 'ds'. */ @@ -236,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