int16_t al_fread16le(ALLEGRO_FILE *f) returns EOF?
Martin Kalbfuß

Is this even possible when the read value is 16 bit wide? Wouldn't EOF represent a number?

Trent Gamblin

Ya, I think you're right (and there are some other similar functions that look wrong too).

Martin Kalbfuß
int32_t al_fread32le(ALLEGRO_FILE *f, bool *ret_success)

doing it right.

But i would prefer

bool al_fread32le(ALLEGRO_FILE *f, int32_t *value);

This way you can do

if (al_fread32le(stream, &number))
{
   ...
}

Matthew Leverton

I suggested this same thing a while ago. I believe the current solution is (or was) to check via an error function.

I don't particularly like the "ret_success" solution either, although perhaps it's better for the rare times that you don't actually want to use a variable to store the data.

ImLeftFooted

Can we have both?

Peter Wang

I suppose "bool al_fread16le(ALLEGRO_FILE *f, int16_t w);" has a certain symmetry with "size_t al_fwrite16le(ALLEGRO_FILE *f, int16_t w);".

Thomas Fjellstrom

If its going to return a status, maybe it should probably also be size_t, and report how much it read back. Of course it provides no way to rescue from a short read, so the information would be mostly useless, but it would match the fwriteNNmm functions and the base fread and fwrite functions.

Just an idea.

Thread #602152. Printed from Allegro.cc