Improve MSVC patch in stk500.c

This commit is contained in:
Marius Greuel 2020-03-10 20:54:32 +02:00
parent e3efb3bce9
commit 13e404d777
1 changed files with 8 additions and 12 deletions

View File

@ -754,10 +754,16 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
return -1;
}
static int stk500_paged_write2(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned char* buf, unsigned int page_size,
static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned int page_size,
unsigned int addr, unsigned int n_bytes)
{
#ifdef _MSC_VER
unsigned char* buf = _alloca(page_size + 16);
#else
unsigned char buf[page_size + 16];
#endif
int memtype;
int a_div;
int block_size;
@ -848,16 +854,6 @@ static int stk500_paged_write2(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return n_bytes;
}
static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned int page_size,
unsigned int addr, unsigned int n_bytes)
{
unsigned char* buf = malloc(page_size + 16);
int result = stk500_paged_write2(pgm, p, m, buf, page_size, addr, n_bytes);
free(buf);
return result;
}
static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned int page_size,
unsigned int addr, unsigned int n_bytes)