Skip to content

Remove dynamic memory allocation from the Wire library [imported] #351

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

Closed
cmaglie opened this issue Nov 15, 2012 · 0 comments
Closed

Remove dynamic memory allocation from the Wire library [imported] #351

cmaglie opened this issue Nov 15, 2012 · 0 comments

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 351 moved from a Google Code project.
Added by 2010-09-14T05:17:42.000Z by ryanfobel.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Enhancement, Priority-Medium, Component-Core, Milestone-0020

Original description

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.

@cmaglie cmaglie closed this as completed Nov 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant