[sane-devel] Number of devices

Alexander Pevzner pzz at apevzner.com
Thu Jan 28 19:23:41 GMT 2021


On 1/28/21 5:40 PM, Thiago Milczarek SayĆ£o wrote:
> Warning: Might be a stupid question.
> 
> const SANE_Device **dev_list;
> sane_get_devices(&dev_list, SANE_FALSE);
> 
> How do I get the size of dev_list?

The returned list (actually, an array) is NULL-terminated, i.e., last 
pointer is NULL.

The returned memory (list itself, devices, device names, etc) is owned 
by backend, so there is no need for caller to free it. But please note, 
that the next call to sane_get_devices() may invalidate ALL the memory, 
returned by the previous call.

-- 

	Wishes, Alexander Pevzner (pzz at apevzner.com)



More information about the sane-devel mailing list