diff options
| author | Junio C Hamano <junkio@cox.net> | 2006-09-27 23:56:55 -0700 |
|---|---|---|
| committer | Junio C Hamano <junkio@cox.net> | 2006-09-27 23:56:55 -0700 |
| commit | 2d5b459107cf07bbb307cfb196c2007c497a6dd2 (patch) | |
| tree | b7f398e90acf62af13709dba1739db30144913ee /interpolate.c | |
| parent | 51b2dd4e3f730f6be6c19faf3b4a04caea9e0420 (diff) | |
| parent | eb30aed7c69190fd648947d54bbb9ebe53c67715 (diff) | |
| download | git-2d5b459107cf07bbb307cfb196c2007c497a6dd2.tar.xz | |
Merge branch 'jl/virtual'
* jl/virtual:
Removed memory leaks from interpolation table uses.
Cleaned up git-daemon virtual hosting support.
Diffstat (limited to 'interpolate.c')
| -rw-r--r-- | interpolate.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/interpolate.c b/interpolate.c index 4570c123dc..62701d8435 100644 --- a/interpolate.c +++ b/interpolate.c @@ -4,9 +4,35 @@ #include <string.h> +#include "git-compat-util.h" #include "interpolate.h" +void interp_set_entry(struct interp *table, int slot, char *value) +{ + char *oldval = table[slot].value; + char *newval = value; + + 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, |
