Re: [AD] resource path functions [was: [patch] new configuration variable: resource_path] |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2004-09-16, Daniel Schlyder <daniel@xxxxxxxxxx> wrote:
> The attached patch adds three new API functions:
>
> int add_allegro_resource_path(AL_CONST char *path, int priority);
> void remove_allegro_resource_path(AL_CONST char *path);
> void remove_all_allegro_resource_paths();
>
> The paths are stored in a linked list, so there's no arbitrary
> limit on how many paths can be added. Paths are sorted from
> highest to lowest priority on insertion so the list can simply
> be iterated through in find_allegro_resource().
>
> I thought about having just one function with NULL having special
> meaning, but I think the interface is cleaner by having separate
> functions for each task. remove_all_allegro_resource_paths()
> was originally an implementation detail, but I exposed it for
> completeness sake; not sure how useful it is.
The argument about having one function to add and another to remove
doesn't hold much strength when you also use the add function to
modify a currently existant path. The problem really is: from the
two parameters (path and priority), which one "drives" the other
one around?
The way you have considered the API, the main parameter seems to
be the path. That's why you have functions to add or remove paths,
the priority seems like an unimportant attribute that just dangles
around and is used for the not so sexy operation of sorting.