title: boost scoped_ptr/shared_ptr holding memory block of different size than size of object pointed to
body: <p>Actually when writting this question, another question a shorter one came to my mind so i will ask it first:</p>
  
  <p>1st Question (Shorter):</p>
  
  <p>I have a header with struct defined in this manner:</p>
  
  <pre><code>typedef struct _CAMERA_LIST
  {
  ....
  }CAMERA_LIST, *PCAMERA_LIST;
  </code></pre>
  
  <p>What is the meaning of this syntax? (note the difference in the struct name and the names after closing brace)</p>
  
  <p>2nd Question (Longer):</p>
  
  <p>I have a code example from hardware manufacturer showing how to properly initialize the hardware that Im using. In the code manufacturer uses raw pointers and in my application i would prefer to use boost scoped_ptr or shared_ptr. The problem is that memory block that i want to allocate is different size than that allocated by regular new ObjectType;</p>
  
  <p>Here is the short version of what i got from the manufacturer's site:</p>
  
  <pre><code>int nNumCam = 3;
  CAMERA_LIST* pucl;
  pucl = (CAMERA_LIST*) new BYTE [sizeof (DWORD) + nNumCam * sizeof (CAMERA_INFO)];
  pucl-&gt;dwCount = nNumCam;
  printf("Camera %i Id: %d", iCamera, pucl-&gt;uci[1].dwCameraID);
  </code></pre>
  
  <p>And here is what i want to get:</p>
  
  <pre><code>int nNumCam = 3;
  scoped_ptr&lt;CAMERA_LIST&gt; pucl;
  pucl.reset( (CAMERA_LIST*) new BYTE [sizeof (DWORD) + nNumCam * sizeof (CAMERA_INFO)] );
  pucl-&gt;dwCount = nNumCam;
  printf("Camera %i Id: %d", iCamera, pucl-&gt;uci[1].dwCameraID);
  </code></pre>
  
  <p>Here is how the struct looks like exactly:</p>
  
  <pre><code>typedef struct _CAMERA_LIST
  {
  DWORD dwCount;
  CAMERA_INFO uci[1];
  }CAMERA_LIST, *PCAMERA_LIST;
  </code></pre>
  
  <p>The question is: How do I get this functionality to work with scoped_ptr/shared_ptr?
  Also note that in the code snippet the deletion of the memory block is done via delete[] not delete. Do i need to use scoped_array? If so how do access struct fields?</p>
  
  <p>there is a complete example from manufacturers site in case anyone finds it helpful:</p>
  
  <pre><code>INT nNumCam;
  if( is_GetNumberOfCameras( &amp;nNumCam ) == IS_SUCCESS) {
  if( nNumCam &gt;= 1 ) {
    // Create new list with suitable size
    CAMERA_LIST* pucl;
    pucl = (CAMERA_LIST*) new BYTE [sizeof (DWORD) + nNumCam * sizeof (CAMERA_INFO)];
    pucl-&gt;dwCount = nNumCam;
  
    //Retrieve camera info
    if (is_GetCameraList(pucl) == IS_SUCCESS) {
      int iCamera;
      for (iCamera = 0; iCamera &lt; (int)pucl-&gt;dwCount; iCamera++) {
        //Test output of camera info on the screen
        printf("Camera %i Id: %d", iCamera,
        pucl-&gt;uci[iCamera].dwCameraID);
      }
    }
  }
  delete [] pucl;
  }
  </code></pre>