-2

I know in c++ delete a newed array by using delete[]. What I am wondering is, what if I just do delete without []. I saw something like this in our company code. And it does no crash the system. Is this also right?

u_char* binBuf2 = new u_char[bitCount + 1];
delete binBuf2;

thanks

BufBills
  • 7,265
  • 9
  • 42
  • 77

1 Answers1

1

No that is not the correct method of freeing up the memory.

Keep in mind that because something doesn't crash the system doesn't mean it's good practice

sedavidw
  • 10,038
  • 12
  • 53
  • 88