Boo0ns / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Remove dynamic memory allocation from the Wire library #351

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

I would like to see dynamic memory allocation removed from the Wire library.

Why?

The length of the dynamically-allocated buffers never changes, so I can't see 
any reason to use dynamic allocation.  It's probably not a big deal for most 
people, but I've recently been struggling with random crashes due to SRAM 
issues (e.g. see http://www.arduino.cc/playground/Code/AvailableMemory); I'm 
not an expert, but my take is that it's better to avoid dynamic memory 
allocation unless it's absolutely necessary.  I can't see any advantages in 
this case, and static allocation simplifies memory profiling...

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

No.

I've modified Wire.h/cpp and twi.c by statically allocating all buffers.  The 
attached patch was made against r959.

Original issue reported on code.google.com by ryanfobel on 14 Sep 2010 at 5:17

Attachments:

GoogleCodeExporter commented 9 years ago
r1089

Original comment by dmel...@gmail.com on 16 Sep 2010 at 12:51