Re: [AD] Allegro5 and colors

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 08 September 2002 22:36, Bob wrote:
> How safe is returning an array from a function?

Aargh, you are right, using arrays is a bad idea. It's late, sorry :-)
Better use a struct: 

struct al_color { char p[8]; }; // or however big

Structures can be returned from functions fine, and are also scalar 
values in some respects (so you can assign them, for instance). Or you 
could use pass-by-reference rather than pass-by-value. But you can't 
compare them :-(

> How fast is it? Does
> speed matter in our case?

It is slightly slower if we pass-by-value, because the compiler can't 
represent structures on the stack, so it passes a pointer and then 
constructs the structure later on. This isn't very significant. If it 
does matter in a certain case (makecol springs to mind), use inline 
functions, in which case there is no function call, so no speed loss.

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9e8xBUdhclgSmRuoRAkztAJ9HbTg5CKGcBLcviEbOmQEdG9fVNgCfRH+I
e5mQfBT4hPXaV8Kwfso70u0=
=qHjc
-----END PGP SIGNATURE-----



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