Skip to content

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

Closed
@cmaglie

Description

@cmaglie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions