def unpack_zeroterm_array(ptr):
 assert ptr
 index = 0
 current = ptr[index]
 while current:
  (yield current)
  free(ffi.cast('gpointer', current))
  index += 1
  current = ptr[index]
 free(ffi.cast('gpointer', ptr))

def unpack_zeroterm_array ( ptr ) : assert ptr index = 0 current = ptr [ index ] while current : ( yield current ) free ( ffi . cast ( 'gpointer' , current ) ) index += 1 current = ptr [ index ] free ( ffi . cast ( 'gpointer' , ptr ) )
converts a zero terminated array to a list and frees each element and the list itself .