From bf386c66394297172d8204a3b9cf9e092ced7d30 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Apr 2024 14:03:09 +0100 Subject: [PATCH 1/2] Make static table const --- src/par.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/par.c b/src/par.c index 76968569..19b613ba 100644 --- a/src/par.c +++ b/src/par.c @@ -51,7 +51,7 @@ struct ppipins_t { int inverted; }; -static struct ppipins_t ppipins[] = { +static const struct ppipins_t ppipins[] = { { 1, PPICTRL, 0x01, 1 }, { 2, PPIDATA, 0x01, 0 }, { 3, PPIDATA, 0x02, 0 }, From 7ddb7500aaabef9d0d8a48a8f4325411ed0de492 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 22 Apr 2024 14:05:56 +0100 Subject: [PATCH 2/2] Utilse magic memory tree interface --- src/avrdude.h | 1 + src/par.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/avrdude.h b/src/avrdude.h index c679a654..6b777d30 100644 --- a/src/avrdude.h +++ b/src/avrdude.h @@ -44,6 +44,7 @@ extern const char *pgmid; // Programmer -c string #define mmt_strdup(s) cfg_strdup(__func__, s) #define mmt_malloc(n) cfg_malloc(__func__, n) #define mmt_realloc(p, n) cfg_realloc(__func__, p, n) +#define mmt_free(p) free(p) int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...); diff --git a/src/par.c b/src/par.c index 19b613ba..84630348 100644 --- a/src/par.c +++ b/src/par.c @@ -334,7 +334,7 @@ static void par_close(PROGRAMMER *pgm) { * parse the -E string */ static int par_parseexitspecs(PROGRAMMER *pgm, const char *sp) { - char *cp, *s, *str = cfg_strdup("par_parseexitspecs()", sp); + char *cp, *s, *str = mmt_strdup(sp); s = str; while((cp = strtok(s, ","))) { @@ -357,13 +357,13 @@ static int par_parseexitspecs(PROGRAMMER *pgm, const char *sp) { pgm->exit_datahigh = EXIT_DATAHIGH_DISABLED; else { - free(str); + mmt_free(str); return -1; } s = NULL; // Only call strtok() once with the actual string } - free(str); + mmt_free(str); return 0; }