X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/e7eb3a2744aa45179daea235800753d3d1955338..refs/heads/master:/lib/vector.c
diff --git a/lib/vector.c b/lib/vector.c
index 6803a14..0d1dd4e 100644
--- a/lib/vector.c
+++ b/lib/vector.c
@@ -1,6 +1,6 @@
/*
* This file is part of DisOrder.
- * Copyright (C) 2004, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2007-2009, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,7 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
+/** @file lib/vector.c
+ * @brief Dynamic array utilities
+ */
#include "common.h"
#include
@@ -36,6 +38,20 @@ void dynstr_append_bytes(struct dynstr *v, const char *ptr, size_t n) {
}
}
+/** @brief Free a string list */
+void free_strings(int nvec, char **vec) {
+ int n;
+ for(n = 0; n < nvec; ++n)
+ xfree(vec[n]);
+ xfree(vec);
+}
+
+/** @brief Free and re-initialize a vector */
+void vector_clear(struct vector *v) {
+ free_strings(v->nvec, v->vec);
+ vector_init(v);
+}
+
/*
Local Variables:
c-basic-offset:2