Track and use length of variable length structs and their varsized array
Created originally on Bitbucket by coronafire (Andrew Leech)
Was already merged in Bitbucket before import, marked as merged by the import user
As discussed in issue #284
This changeset records the allocated memory size when creating a new struct, which can then be used directly when getting ffi.buffer()
on said struct.
This is particularly useful when variable sized structs are used, as the typedef/sizeof does not directly relate the size of the allocated size.
This information can also be used when accessing the varsized_array[]
field of the struct to return an array of the correct allocated size.