title: ctypes c++ function returns array of unknown size
body: <p>I have a c++ function that accepts a Pointer to an array of known size as input and returns an array of size that cannot be determined until the function completes its processing of data. How do I call the c++ function, passing the first array and receive the results as a second array?</p>
  
  <p>I currently do something similar to this:</p>
  
  <p>PYTHON:</p>
  
  <pre><code>def callout(largeListUlonglongs):
      cFunc = PyDLL("./cFunction.dll").processNumbers
  
      arrayOfNums = c_ulonglong * len(largeListUlonglongs)
      numsArray = arrayOfNums()
  
      for x in xrange(len(largeListUlonglongs)):
          numsArray[x] = long(largeListUlonglongs[x])
  
      cFunc.restype = POINTER(c_ulonglong * len(largeListUlonglongs))
  
      returnArray = cFunc(byref(numsArray)).contents
  
      return returnArray
  </code></pre>
  
  <p>This works so long as the returnArray is of the same size as the numsArray. If it is smaller then the empty elements of the array are filled with 0's. If the returned array is larger than the results get cut off once the array elements are filled.</p>
  
  <p>If it helps, the structure of the returned array contains the size of the returned array as its first element.</p>
  
  <p>Thanks for the help in advance...</p>