-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
  • 8,005
  • 12
  • 48
  • 90

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
  • 11,116
  • 13
  • 61
  • 95