Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd7f61a

Browse files
benmalenfantfpistm
authored andcommitted
Fix Wire memory leak
Signed-off-by: Benoit Malenfant <25072667+benmalenfant@users.noreply.github.com>
1 parent3a3ff84 commitbd7f61a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎libraries/Wire/src/Wire.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,23 @@ TwoWire::TwoWire()
3838
memset((void *)&_i2c,0,sizeof(_i2c));
3939
_i2c.sda =digitalPinToPinName(SDA);
4040
_i2c.scl =digitalPinToPinName(SCL);
41+
42+
txBuffer =nullptr;
43+
txBufferAllocated =0;
44+
rxBuffer =nullptr;
45+
rxBufferAllocated =0;
4146
}
4247

4348
TwoWire::TwoWire(uint32_t sda,uint32_t scl)
4449
{
4550
memset((void *)&_i2c,0,sizeof(_i2c));
4651
_i2c.sda =digitalPinToPinName(sda);
4752
_i2c.scl =digitalPinToPinName(scl);
53+
54+
txBuffer =nullptr;
55+
txBufferAllocated =0;
56+
rxBuffer =nullptr;
57+
rxBufferAllocated =0;
4858
}
4959

5060
/**
@@ -74,14 +84,10 @@ void TwoWire::begin(uint8_t address, bool generalCall, bool NoStretchMode)
7484
{
7585
rxBufferIndex =0;
7686
rxBufferLength =0;
77-
rxBuffer =nullptr;
78-
rxBufferAllocated =0;
7987
resetRxBuffer();
8088

8189
txDataSize =0;
8290
txAddress =0;
83-
txBuffer =nullptr;
84-
txBufferAllocated =0;
8591
resetTxBuffer();
8692

8793
_i2c.__this = (void *)this;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp