Re: [AD] load_datafile_object with properties |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sat, 2002-10-05 at 22:52, Eric Botcazou wrote:
..
Agreed to everything, I'll try fixing it :)
>
> + /* both read_property and read_single_object use *allegro_errno
> + for error reporting */
> if (*allegro_errno) {
> unload_datafile(dat);
> -
> - for (c=0; c<MAX_PROPERTIES; c++)
> - if (prop[c].dat)
> - free(prop[c].dat);
> -
> - return NULL;
> + dat = NULL;
> + break;
>
> You still have to free the property list here.
That's what the break is for, it should jump right to the freeing code.
Once the properties are added to the datafile, 'properties' is set to
NULL and the unload_datafile frees them.
> + /* concatenate to filename#objectname, to avoid recursion later */
> + ustrzcpy(parent, sizeof(parent), filename);
> +
> + if (ustrcmp(parent, uconvert_ascii("#", tmp)) != 0)
> + ustrzcat(parent, sizeof(parent), uconvert_ascii("#", tmp));
> +
> + ustrzcat(parent, sizeof(parent), objectname);
> +
> + /* separate into path and actual objectname (for nested files) */
> + prevptr = bufptr = parent;
> + while ((c = ugetx(&bufptr)) != 0) {
> + if ((c == '#') || (c == '/') || (c == OTHER_PATH_SEPARATOR)) {
> + separator = prevptr;
> + }
> + prevptr = bufptr;
> + }
> +
> + ustrzcpy(child, sizeof(child), separator + uwidth (separator));
>
> I don't understand: you concatenate then split at the concatenation point.
> Aren't you guaranteed that child == objectname, even for nested datafiles,
> given that objectname can't contain the # character ? Moreover, why to
> compare against / and OTHER_PATH_SEPARATOR ?
With the old code, objectname can contain # characters, as well as / and
OTHER_PATH_SEPARATOR. The datafile name is just concatenated with # and
the object name, then passed directly to pack_fopen - which understands
everything.
Because I didn't want to include recursive searching, I concatenate as
before, then strip right before the last item in the path (child) and
pass everything else (parent) to pack_fopen - and only need to search
'child' non-recursivly in the opened file.
--
Elias Pschernig