X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=interpolate.c;h=fb30694f4741147bba62350f704111d3afbf8133;hb=3a55602eeca4ac8670e8698a7187e18b95683344;hp=4570c123dce811bab8a89efe4c3b4a9a977e6c5a;hpb=1ad7a06adb6fbe42357daa58738008cbadbb8650;p=thirdparty%2Fgit.git diff --git a/interpolate.c b/interpolate.c index 4570c123dc..fb30694f47 100644 --- a/interpolate.c +++ b/interpolate.c @@ -2,11 +2,35 @@ * Copyright 2006 Jon Loeliger */ -#include - +#include "git-compat-util.h" #include "interpolate.h" +void interp_set_entry(struct interp *table, int slot, const char *value) +{ + char *oldval = table[slot].value; + char *newval = NULL; + + if (oldval) + free(oldval); + + if (value) + newval = xstrdup(value); + + table[slot].value = newval; +} + + +void interp_clear_table(struct interp *table, int ninterps) +{ + int i; + + for (i = 0; i < ninterps; i++) { + interp_set_entry(table, i, NULL); + } +} + + /* * Convert a NUL-terminated string in buffer orig * into the supplied buffer, result, whose length is reslen, @@ -31,7 +55,7 @@ int interpolate(char *result, int reslen, const char *src = orig; char *dest = result; int newlen = 0; - char *name, *value; + const char *name, *value; int namelen, valuelen; int i; char c;