Re: [AD] load_datafile_object using index |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Monday 18 April 2005 20:42, Elias Pschernig wrote:
> On Mon, 2005-04-18 at 19:48 +0200, spoofer255@xxxxxxxxxx wrote:
> > I made a patch that add indexed support for loading single datafile
> > objects. Here is small example how to use it:
> >
> > -- cut --
> >
> > long index[DATA_COUNT] //defined in data.h (grabber)
> > DATAFILE *data;
> >
> > if (load_datafile_indexed("filename", index) != 0)
> > //report error
> >
> > data = load_datafile_object_indexed("filename", index[DATA_ALIEN]);
> > if (!data)
> > //report error
> >
> > -- cut --
> >
> > It's just like normal load_datafile_object, only faster because it
> > doesn't search for name but fseeks to offset. Any chance it can be
> > added into 4.3?
>
> I like it. [Hm, must resist the urge to suggest putting it even into
> 4.2.0.. ]
Hehe... so do I. Perhaps if we unanimously agree that it should and can be
included...? Probably a bad idea, but still...
This really is a feature that has been lacking for a long time too. It's a
shame the patch came this late. I suppose it would do fine as an addon to
4.2 even when it is merged with 4.3.
Anyway, my main point of criticism at the moment is the API itself. I would
prefer either (apart from load_datafile_indexed->load_datafile_index)
int *load_datafile_index(const char *fname, int *indexc, int **indexv)
where the routine itself allocates the array and returns the pointer in
indexv as well as through the return value and the size in indexc, or
int load_datafile_index(const char *fname, int indexc, int *indexv)
where the user specifies the size of the array and the routine fails with
an errorcode if it is not large enough. The proposed fixed-size array that
has to be large enough is too inflexible and insecure. We probably should
also have a version that takes a DATAFILE object as argument instead of a
filename.
Evert