firmata/arduino — pull request #76 by soundanalogous (2013-08-01 02:31:08+00:00)
Title: fixed memory leak in string buffer

See this [issue](https://github.com/firmata/arduino/issues/74).

The string buffer memory was never freed in the past. This is a long standing bug. I'd just merge this but want to make sure that no one has any concerns about the implementation. The buffer is freed after the stringCallback returns. If anyone still needed a reference to the string after the callback returns, the reference would be lost (maybe I've just been writing too much JavaScript lately and this is a non-issue in c since it's procedural).

The alternative however is less attractive. That is to rely on the user to free the pointer in their callback function. If they fail to do this and are sending multiple strings from their client application, they'll eventually crash their arduino sketch.

Also added a unit test to verify memory is now properly freed. Uncommented memory test for setFirmwareVersion as well so now all allocated memory is tested that it is properly freed.

Any comments?