Linked Questions

2 votes
1 answer
317 views

What happens when you call malloc()/free()/new/delete?

So I understand that generally speaking, dynamic allocation should be avoided. My question isn't how or why, but what happens when you call a function that allocates memory? On Windows or Linux, when ...
Dan Forever's user avatar
1 vote
0 answers
434 views

Understanding heap fragmentation

I finally understand why people do not allocate memory when it comes to micro-controllers. The reason is because as you allocate different objects on the heap of various sizes and then you delete them ...
Tono Nam's user avatar
  • 938
12 votes
4 answers
8k views

Why is it considered bad practice to use the 'new' keyword in Arduino?

I previously asked this question: Is it required to delete variables before going to sleep? On that question, @Delta_G posted this comment: ... Really on a microcontroller I would create the object ...
Tono Nam's user avatar
  • 938
0 votes
2 answers
104 views

Add char at intervals in a String

I'm trying to create a function that will take a String as an input, and at every 20 characters, it will instert "\n" so that the string doesn't go off the side of my screen (I'm using an ...
user avatar
0 votes
2 answers
1k views

How to write a function to return matrix?

I need a function to return a 2x2 rotation matrix, something like: float matrix(float phi){ float R[2][2] = { {cos(phi), -sin(phi)}, {sin(phi), cos(phi)} }; return R; } But ...
2012User's user avatar
  • 149
2 votes
3 answers
1k views

Using malloc() and free() for a stack/linkedlist [closed]

I know this question has been asked before, however it was asked two years ago and I have some other constraints to add. (Previous question here) : Is using malloc() and free() a really bad idea on ...
Brydon Gibson's user avatar
6 votes
1 answer
662 views

Understanding global variables on Arduino

I am rewriting a set of LED manipulation functions to be more object oriented, and I have found that, mysteriously, my global variable memory space has been over consumed, despite a reduction of the ...
watusimoto's user avatar
3 votes
2 answers
4k views

AVR - How to know that there is collision between stack and heap or the memory has filled?

I am using the dynamic memory in AVR microcontroller, so How to know that there is collision between stack and heap or if the memory has been filled?
Ahmad Naoum's user avatar
2 votes
3 answers
196 views

Simple compiler design help: Variable length arrays in Arduino?

I'm trying to write a simple compiler in the Arduino language that I am making up for my lab. The compiler will have to be able to turn a string like this: "do command_one 3 times" into a data ...
Paul Terwilliger's user avatar
0 votes
1 answer
7k views

Slice string at “:”

I need to slice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is ...
user3826856's user avatar
19 votes
5 answers
187k views

How can I declare an array of variable size (Globally)

I'd like to make three arrays of the same length. According to the documentation, Arrays must be defined as int myArray[10]; where 10 can be substituted for a known length (another integer), or filled ...
user3.1415927's user avatar