[dpdk-dev] [PATCH v4 2/2] cmdline: make struct rdline opaque
Olivier Matz
olivier.matz at 6wind.com
Wed Oct 6 10:11:40 CEST 2021
Hi Dmitry,
On Tue, Oct 05, 2021 at 11:15:45PM +0300, Dmitry Kozlyuk wrote:
> Hide struct rdline definition and some RDLINE_* constants in order
> to be able to change internal buffer sizes transparently to the user.
> Add new functions:
>
> * rdline_new(): allocate and initialize struct rdline.
> This function replaces rdline_init() and takes an extra parameter:
> opaque user data for the callbacks.
> * rdline_free(): deallocate struct rdline.
> * rdline_get_history_buffer_size(): for use in tests.
> * rdline_get_opaque(): to obtain user data in callback functions.
>
> Remove rdline_init() function from library headers and export list,
> because using it requires the knowledge of sizeof(struct rdline).
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
[...]
> /**
> - * Init fields for a struct rdline. Call this only once at the beginning
> - * of your program.
> - * \param rdl A pointer to an uninitialized struct rdline
> + * Allocate and initialize a new rdline instance.
> + *
> + * \param rdl Receives a pointer to the allocated structure.
> * \param write_char The function used by the function to write a character
> * \param validate A pointer to the function to execute when the
> * user validates the buffer.
> * \param complete A pointer to the function to execute when the
> * user completes the buffer.
> + * \param opaque User data for use in the callbacks.
> + *
> + * \return 0 on success, negative errno-style code in failure.
> */
> -int rdline_init(struct rdline *rdl,
> - rdline_write_char_t *write_char,
> - rdline_validate_t *validate,
> - rdline_complete_t *complete);
> +__rte_experimental
> +struct rdline *rdline_new(rdline_write_char_t *write_char,
> + rdline_validate_t *validate,
> + rdline_complete_t *complete,
> + void *opaque);
The API documentation was not updated after the v4 changes.
Apart from this, LGTM, you can directly add my ack in the next version.
Thanks,
Olivier
More information about the dev
mailing list