title: Will this C++ code cause a memory leak (casting array new)
body: <p>I have been working on some legacy C++ code that uses variable length structures (TAPI), where the structure size will depend on variable length strings. The structures are allocated by casting array <code>new</code> thus:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>STRUCT* pStruct = (STRUCT*)new BYTE[sizeof(STRUCT) + nPaddingSize];
  </code></pre>
  
  <p>Later on however the memory is freed using a <code>delete</code> call:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>delete pStruct;
  </code></pre>
  
  <p>Will this mix of array <code>new[]</code> and non-array <code>delete</code> cause a memory leak or would it depend on the compiler?  Would I be better off changing this code to use <code>malloc</code> and <code>free</code> instead?</p>