Skip to content

Add trivial new[] and delete[] operators #73

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
wants to merge 3 commits into from
Closed

Add trivial new[] and delete[] operators #73

wants to merge 3 commits into from

Conversation

jrcutler
Copy link

@jrcutler jrcutler commented Apr 9, 2012

Simple new and delete operators exist in <new.h> and <new.cpp>, but the new[] and delete[] operators do not.

Test case: (should compile, but currently does not)

class Buffer
{
public:
  Buffer(size_t len): data(new uint8_t[len]), len(len) {}
  ~Buffer() { delete[] data; }
  uint8_t * const data;
  const size_t len;
};

Buffer b(16);

void setup()
{
  for (size_t i=0; i<b.len; ++i)
    b.data[i] = 0;
}

void loop() {}

@jrcutler
Copy link
Author

jrcutler commented Apr 9, 2012

See Issue 883.

@jrcutler
Copy link
Author

The previous commit should not have referenced this pull request.

@gzip
Copy link

gzip commented Jun 19, 2012

+1

@kibergus
Copy link

Please don't apply this pull request because it contradicts C++ standard. operator new[] must be implemented in other way. Please look at
https://github.com/kibergus/StandardCplusplus/blob/master/new
for correct declarations of operator new and new_.cpp del_.cpp for it's realization.

Also operator new from arduino has wrong realization too. Please use one from uclibc++ or, as a better solution, include uclibc++ in arduino distribution.

zacmanchester referenced this pull request in zacmanchester/Energia Aug 23, 2012
Issue 53 - Fix for delay() freeze after Flash.erase and Flash.read
@cmaglie cmaglie closed this in 141684d Dec 17, 2012
@cmaglie
Copy link
Member

cmaglie commented Dec 17, 2012

Merged thanks.

@kibergus
Copy link

Damn! Why do you fix it WRONG WAY!? Your code

  1. does not conform to C++ standard
  2. unreliable
  3. incomplete

Please read:
http://arduino.cc/forum/index.php/topic,119127.msg896385.html#msg896385

And please use CORRECT patches which you've been provided!

oriregev pushed a commit to oriregev/Arduino that referenced this pull request Dec 20, 2013
tbowmo pushed a commit to tbowmo/Arduino that referenced this pull request Jul 14, 2016
…alid_gw_input

Revert "check for invalid input on gateway"
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

Successfully merging this pull request may close these issues.

6 participants