X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdynamic-string.c;h=9684ffad89b3c68b81b2b02745e2c46dfe6aafea;hb=da0603cf278a9f505dc2988602ec0071c771dd2e;hp=7e4843d1bbf069650bdf735155571e1e804188c2;hpb=a14bc59fb8f27db193d74662dc9c5cb8237177ef;p=openvswitch diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 7e4843d1..9684ffad 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Nicira Networks. + * Copyright (c) 2008, 2009 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -187,6 +187,17 @@ ds_cstr(struct ds *ds) return ds->string; } +/* 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'. */ +char * +ds_steal_cstr(struct ds *ds) +{ + char *s = ds_cstr(ds); + ds_init(ds); + return s; +} + void ds_destroy(struct ds *ds) {