30. Dynamic Memory Allocation-i

Question.8

A firmware architect allows new only during initialization, never inside the main loop. Why is this acceptable?

void system_init() {
   uart_buf = new uint8_t[UART_BUF_SIZE];
   sensor  = new Sensor(I2C_BUS);
}

int main() {
   system_init();
   while (true) { /* NEVER call new/delete here */ }
}
Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!