Index: [thread] [date] [subject] [author]
  From: becka@rz.uni-duesseldorf.de
  To  : ggi-develop@eskimo.com
  Date: Thu, 22 Apr 1999 00:10:04 +0200 (MEST)

Re: GGI help

> > The result is not undefined, ggiSetPalette() returns <0 on failure,
> > whatever the reason may be. The reason that ggiSetColorfulPalette()
> > fails in this thread is that it needs to allocate (1<<GT_DEPTH(mode))*8
> > bytes of memory.

> Oh yes, you're right, but why try to allocate memory when you know
> ggiSetPalette() will fail (not palettized mode).  Or ggiSetPalette() can
> conceivably work in that case?  Otherwise programs will have to check
> for palettized mode before calling ggiSetColorfulPalette() anyway.

Well - actually I don't see a problem here. What I meant with undefined,
is "the result on the image is not defined, in case it _would_ work".

Basically Marcus is just right:

It doesn't matter, why the command fails, as long as it fails cleanly.
If you do not check for a palettized mode, but then _do_ check for the
RC for SetColorfulPalette, well - it's your fault.

Either don't check at all, which will work. This calls SetColorfulPalette
unnecessarily and allocates a bunch of unnneeded memory for a short while,
but so what. SetColorfulPalette returns with an error code as it should,
no matter if it failed to to lack of RAM or due to SetPalette failing,
with no harm done.

Or you check for a palettized mode beforehand, which avoids requiring
the library code to do so. I think this should be the recommended
solution.

CU, ANdy

-- 
= Andreas Beck                    |  Email :  <andreas.beck@ggi-project.org> =

Index: [thread] [date] [subject] [author]