Removed memory leaks from interpolation table uses.
Clarified that parse_extra_args()s results in interpolation table entries. Removed a few trailing whitespace occurrences. Signed-off-by: Jon Loeliger <jdl@jdl.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
dd4676299d
commit
eb30aed7c6
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user