• R/O
  • SSH
  • HTTPS

avrdude: Commit


Commit MetaInfo

Revision1460 (tree)
Zeit2020-01-21 04:07:51
Autorgottfried

Log Message

removed crazy alloca

Ändern Zusammenfassung

Diff

--- trunk/buspirate.cpp (revision 1459)
+++ trunk/buspirate.cpp (revision 1460)
@@ -40,9 +40,6 @@
4040 #include <stdlib.h>
4141 #include <string.h>
4242 #include <unistd.h>
43-#if defined(WIN32NATIVE)
44-# include <malloc.h> /* for alloca() */
45-#endif
4643
4744 #include "avrdude.h"
4845 #include "libavrdude.h"
@@ -134,20 +131,23 @@
134131 }
135132
136133 static int buspirate_expect_bin(struct programmer_t *pgm,
137- unsigned char *send_data, size_t send_len,
138- unsigned char *expect_data, size_t expect_len)
134+ unsigned char *send_data, size_t send_len,
135+ unsigned char *expect_data, size_t expect_len)
139136 {
140- unsigned char *recv_buf = static_cast<unsigned char*>(alloca(expect_len));
141- if ((pgm->flag & BP_FLAG_IN_BINMODE) == 0) {
142- avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode\n");
143- return -1;
144- }
137+ if((pgm->flag & BP_FLAG_IN_BINMODE) == 0)
138+ {
139+ avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode\n");
140+ return -1;
141+ }
142+ unsigned char *recv_buf = static_cast<unsigned char*>(malloc(expect_len));
145143
146- buspirate_send_bin(pgm, send_data, send_len);
147- buspirate_recv_bin(pgm, recv_buf, expect_len);
148- if (memcmp(expect_data, recv_buf, expect_len) != 0)
149- return 0;
150- return 1;
144+ buspirate_send_bin(pgm, send_data, send_len);
145+ buspirate_recv_bin(pgm, recv_buf, expect_len);
146+ int result = memcmp(expect_data, recv_buf, expect_len);
147+ free(recv_buf);
148+ if(result != 0)
149+ return 0;
150+ return 1;
151151 }
152152
153153 static int buspirate_expect_bin_byte(struct programmer_t *pgm,
@@ -504,7 +504,7 @@
504504 /*.name =*/ "Raw-wire",
505505 /*.enter =*/ 0x05,
506506 /*.entered_format =*/ "RAW%1d",
507- /*.config =*/ static_cast<char>(0x8C),
507+ /*.config =*/ (char)0x8C,
508508 };
509509 const struct submode submodule_spi =
510510 {
@@ -517,7 +517,7 @@
517517 * trailing edge (1), sample in the middle
518518 * of the pulse (0)
519519 * => 0b10001010 = 0x8a */
520- /*.config =*/ static_cast<char>(0x8A),
520+ /*.config =*/ (char)0x8A,
521521 };
522522
523523 if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) {
Show on old repository browser