Fix mismatched free/delete

Bug #65553
Fix memory leak
Fix mismatched allocation and deallocation

Part of bug #65551
Prefer prefix ++/-- operators for non-primitive types

Part of bug #80537