mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 11:23:54 +08:00
Pigeon::receive: reserve 4kb+64b for std::string (#19951)
* receive: reserve 4kb+64b for std::string * fix bug
This commit is contained in:
@@ -105,11 +105,11 @@ void PandaPigeon::send(const std::string &s) {
|
||||
|
||||
std::string PandaPigeon::receive() {
|
||||
std::string r;
|
||||
|
||||
while (true){
|
||||
unsigned char dat[0x40];
|
||||
r.reserve(0x1000 + 0x40);
|
||||
unsigned char dat[0x40];
|
||||
while (r.length() < 0x1000){
|
||||
int len = panda->usb_read(0xe0, 1, 0, dat, sizeof(dat));
|
||||
if (len <= 0 || r.length() > 0x1000) break;
|
||||
if (len <= 0) break;
|
||||
r.append((char*)dat, len);
|
||||
}
|
||||
|
||||
@@ -190,13 +190,13 @@ void TTYPigeon::send(const std::string &s) {
|
||||
|
||||
std::string TTYPigeon::receive() {
|
||||
std::string r;
|
||||
|
||||
while (true){
|
||||
char dat[0x40];
|
||||
r.reserve(0x1000 + 0x40);
|
||||
char dat[0x40];
|
||||
while (r.length() < 0x1000){
|
||||
int len = read(pigeon_tty_fd, dat, sizeof(dat));
|
||||
if(len < 0) {
|
||||
handle_tty_issue(len, __func__);
|
||||
} else if (len == 0 || r.length() > 0x1000){
|
||||
} else if (len == 0){
|
||||
break;
|
||||
} else {
|
||||
r.append(dat, len);
|
||||
|
||||
Reference in New Issue
Block a user