X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/812b526d127c6657e571db8b33a58137af6709cd..0c1d42ad03f7e49b23755209f5b1f295cbe21f6b:/lib/vector.c diff --git a/lib/vector.c b/lib/vector.c index 4d798f1..fa8f9e3 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 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 @@ -38,6 +38,19 @@ 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) { + for(int 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