Skip to main content
added 1 characters in body
Source Link
MiMo
  • 12k
  • 1
  • 35
  • 48

The problem is

uint16_t data[(res+1)*(res+1)]; 

it is a local array of 416 MB+ that is too big to fit in the stack (usually 1 MB) - you have to create it in the heap with a new statement:

uint16_t* data = new uint16_t[(res+1)*(res+1)]; 

and then remember to de-allocate it with a delete statement when you don't need it any more:

delete[] data;

The problem is

uint16_t data[(res+1)*(res+1)]; 

it is a local array of 4 MB+ that is too big to fit in the stack (usually 1 MB) - you have to create it in the heap with a new statement:

uint16_t* data = new uint16_t[(res+1)*(res+1)]; 

and then remember to de-allocate it with a delete statement when you don't need it any more:

delete[] data;

The problem is

uint16_t data[(res+1)*(res+1)]; 

it is a local array of 16 MB+ that is too big to fit in the stack (usually 1 MB) - you have to create it in the heap with a new statement:

uint16_t* data = new uint16_t[(res+1)*(res+1)]; 

and then remember to de-allocate it with a delete statement when you don't need it any more:

delete[] data;
Source Link
MiMo
  • 12k
  • 1
  • 35
  • 48

The problem is

uint16_t data[(res+1)*(res+1)]; 

it is a local array of 4 MB+ that is too big to fit in the stack (usually 1 MB) - you have to create it in the heap with a new statement:

uint16_t* data = new uint16_t[(res+1)*(res+1)]; 

and then remember to de-allocate it with a delete statement when you don't need it any more:

delete[] data;