Utilise magic memory tree interface for flip2.c

This commit is contained in:
Stefan Rueger
2024-04-21 17:45:45 +01:00
parent 298d59004b
commit 01a259c36a
2 changed files with 6 additions and 11 deletions

View File

@@ -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, ...);

View File

@@ -493,7 +493,7 @@ static int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const A
// Parse the -E option flag
static int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) {
char *cp, *s, *str = cfg_strdup("flip2_parseextitspecs()", sp);
char *cp, *s, *str = mmt_strdup(sp);
s = str;
while ((cp = strtok(s, ","))) {
@@ -506,11 +506,11 @@ static int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) {
pgm->exit_reset = EXIT_RESET_DISABLED;
continue;
}
free(str);
mmt_free(str);
return -1;
}
free(str);
mmt_free(str);
return 0;
}
@@ -528,17 +528,11 @@ static int flip2_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, cons
}
static void flip2_setup(PROGRAMMER *pgm) {
pgm->cookie = calloc(1, sizeof(struct flip2));
if (pgm->cookie == NULL) {
pmsg_error("out of memory allocating private data structure\n");
exit(1);
}
pgm->cookie = mmt_malloc(sizeof(struct flip2));
}
static void flip2_teardown(PROGRAMMER *pgm) {
free(pgm->cookie);
pgm->cookie = NULL;
mmt_free(pgm->cookie);
}
/* INTERNAL FUNCTION DEFINITIONS