Hi On 2021-05-11 at 09:52 +0200, Samuel Thibault <[email protected]> wrote: > Aura Kelloniemi, le mar. 11 mai 2021 09:49:04 +0300, a ecrit: > > And what about a field (at the end of the struct) that tells the maximum > > size > > of the parameter value array (in bytes or elements)? Or is there already a > > way > > to know how much space to allocate for a parameter value?
> The current count field is to provide this information. > For variable values, brlapi_getParameter returns the actually needed > size, so you can re-allocate a bigger buffer. Or to avoid a round-trip > you can use getParameterAlloc which immediately allocates the proper > size. getParameterAlloc knows the maximum possible size of a parameter – it does not need to do any round-tripping. Is there a reason why this information couldn't be available somewhere – a global constant (BRLAPI_PARAM_VALUE_MAX_SIZE) or preferably per-parameter in its properties. Everything below considers the case where .isArray == true, until otherwise stated. If you are to add a flag which tells that an array has a variable size, couldn't the current .count field tell the maximum possible size? Or can the value be arbitrarily big (in which case unnecessary allocation should be avoided)? I am trying to find a way to make the API as simple as possible, but not so simple that it complicates bindings' writing. This is the reason I would like the maximum size to be easily available, and also why I would like to have uniform handling for all arrays – strings included. And then I'll ask about the case where .siArray == false: Shouldn't this too be very simple? The parameter will hold just one value – i.e. one int, one bool, one char, nothing that is variable-length. Do you disagree? -- Aura _______________________________________________ This message was sent via the BRLTTY mailing list. To post a message, send an e-mail to: [email protected] For general information, go to: http://brltty.app/mailman/listinfo/brltty
