From f10a48ce3a3c4d36fedcca183e48e72ec2ce0355 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 9 Jul 2008 17:22:17 -0700 Subject: [PATCH] New function ds_clear(). --- include/dynamic-string.h | 1 + lib/dynamic-string.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/dynamic-string.h b/include/dynamic-string.h index e43d006a..ea69c6af 100644 --- a/include/dynamic-string.h +++ b/include/dynamic-string.h @@ -49,6 +49,7 @@ struct ds { #define DS_EMPTY_INITIALIZER { NULL, 0, 0 } void ds_init(struct ds *); +void ds_clear(struct ds *); void ds_reserve(struct ds *, size_t min_length); void ds_put_char(struct ds *, char); void ds_put_cstr(struct ds *, const char *); diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 68dd3419..f08e8cb5 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -45,6 +45,12 @@ ds_init(struct ds *ds) ds->allocated = 0; } +void +ds_clear(struct ds *ds) +{ + ds->length = 0; +} + void ds_reserve(struct ds *ds, size_t min_length) { -- 2.30.2