Re: [AD] mode-list API.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> rewrote the mode-list API and updated the docs.

I find the API confusing: who really owns the GFX_MODE_LIST object ? That's
not clear at all, neither in the API nor in the docs. And IMHO using a mix
between statically allocated and dynamically allocated lists is dangerous.

If the user program owns it, then a best way IMHO is to provide the
following API:
   GFX_MODE_LIST *create_gfx_mode_list(int card);
   void destroy_gfx_mode_list(GFX_MODE_LIST *mode_list);
so that the user clearly knows that, between the two calls, he can do
whatever he wants with the GFX_MODE_LIST object (swapping, removing
entries). In this case, the creator function create_gfx_mode_list() must
instantiate a new object each time it is called, even though the same card
parameter has already been used.

If the object belongs to the library, then the API should be:
   const GFX_MODE_LIST *get_gfx_mode_list(int card);
   void release_gfx_mode_list(int card);
so that the user clearly knows that one list at most exists for each card
and that he can't modify it by any means.

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/