-
Notifications
You must be signed in to change notification settings - Fork 517
fixed memory leak in string buffer #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b1c78c5
04b04d5
9e5d2b8
f1c6f12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,21 +18,6 @@ void loop() | |
| Test::run(); | ||
| } | ||
|
|
||
| // Note: this test required adding a method (Firmata.unsetFirmwareVersion()) to | ||
| // Firmata.cpp solely for the purpose of running this test. The method has been | ||
| // removed from Firmata.cpp, but keeping the test here as a recored | ||
| // test(setFirmwareVersionDoesNotLeakMemory) | ||
| // { | ||
| // Firmata.setFirmwareVersion(1, 0); | ||
| // int initialMemory = freeMemory(); | ||
|
|
||
| // Firmata.setFirmwareVersion(1, 0); | ||
|
|
||
| // assertEquals(0, initialMemory - freeMemory()); | ||
|
|
||
| // Firmata.unsetFirmwareVersion(); | ||
| // } | ||
|
|
||
| test(beginPrintsVersion) | ||
| { | ||
| FakeStream stream; | ||
|
|
@@ -61,6 +46,10 @@ void processMessage(const byte* message, size_t length) | |
| } | ||
| } | ||
|
|
||
| void stringCallback(char *myString) | ||
| { | ||
| } | ||
|
|
||
| byte _digitalPort; | ||
| int _digitalPortValue; | ||
| void writeToDigitalPort(byte port, int value) | ||
|
|
@@ -140,3 +129,28 @@ test(specifiedDigitalWritePort) | |
|
|
||
| assertEqual(1, _digitalPort); | ||
| } | ||
|
|
||
| test(stringDataDoesNotLeakMemory) | ||
| { | ||
| Firmata.attach(STRING_DATA, stringCallback); | ||
|
|
||
| int initialMemory = freeMemory(); | ||
|
|
||
| byte stringMsg[] = { START_SYSEX, STRING_DATA, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, END_SYSEX }; | ||
|
|
||
| for (int i = 0; i < 4; i++) { | ||
| processMessage(stringMsg, 13); | ||
| } | ||
|
|
||
| assertEqual(0, initialMemory - freeMemory()); | ||
|
||
| } | ||
|
|
||
| test(setFirmwareVersionDoesNotLeakMemory) | ||
| { | ||
| Firmata.setFirmwareVersion(1, 0); | ||
| int initialMemory = freeMemory(); | ||
|
|
||
| Firmata.setFirmwareVersion(1, 0); | ||
|
|
||
| assertEqual(0, initialMemory - freeMemory()); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this so I could test in my client application. All examples should probably be updated to use these constants.