Initialize buffer for ccall

I am making progress slowly. Thanks Steve I have ccall finding the count working. I believe C generates the total memory required by using the count function as follows:

   info_list = (struct HatInfo*)malloc(info_count * sizeof(struct HatInfo));

This means the number of items in the array can be calculated ahead of time.

Thanks to joa-quim I have updated my struct and am generating a data structure in Julia that should match the size generated in C. My code now works, except for when I uncomment (shown uncommented below) the second ccall function, it won’t compile then with the following message:

could not evaluate ccall argument type (it might depend on a local variable)

Code shown below:

# Global functions and data - https://mccdaq.github.io/daqhats/c.html

mutable struct HatInfo
    address::UInt8 			# The board address.
    id::UInt16 				# The product ID, one of [HatIDs](@ref HatIDs)
    version::UInt16 		# The hardware version
    product_name::NTuple{256,UInt8}	# The product name (c - initialized to 256 characters)
end


"""
	hat_list(filter_id)
Return a list of detected DAQ HAT boards.
"""
function hat_list(filter_id::String)
	idDict = Dict{String, UInt32}(
	"HAT_ID_ANY"     => 0,  	 # Match any DAQ HAT ID in hat_list().
	"HAT_ID_MCC_118" => 0x0142,  # MCC 118 ID.
	"HAT_ID_MCC_118_BOOTLOADER" => 0x8142,  # MCC 118 in firmware update mode ID.
	"HAT_ID_MCC_128" => 0x0146,  # MCC 128 ID.
	"HAT_ID_MCC_134" => 0x0143,  # MCC 134 ID.
	"HAT_ID_MCC_152" => 0x0144,  # MCC 152 ID.
	"HAT_ID_MCC_172" => 0x0145)  # MCC 172 ID.
	
	count = ccall((:hat_list, "/usr/local/lib/libdaqhats"), 
	Cint, (UInt16, Ptr{Cvoid}), idDict["HAT_ID_ANY"], C_NULL)
	@show(count)
	list = Vector{HatInfo}(undef,count)
	@show(list)
	for i = 1:count
		list[i] = HatInfo(0, 0, 0, map(UInt8, (string(repeat(" ",256))...,)))
	end
	
	success = ccall((:hat_list, "/usr/local/lib/libdaqhats"), 
	Cint, (UInt16, Ptr{list}), idDict[filter_id], list)
#	String([list.product_name...])
#	list = unsafe_load(Ptr{HatInfo}(list))
end

I suspect that my Ptr{list} should be a Ref{list} and that somehow I need to get the pointer to list rather than the variable list, but am not sure how to do that with my data structure. Thanks in advance.