ali@rocky.STANFORD.EDU (Ali Ozer) (12/22/87)
[] A chip-memory hog program of mine was losing 256 bytes whenever it failed to open a hires, 4-bit plane, interlaced screen. I finally tracked the problem to the OpenScreen() calls in the following routine. Seems like when OpenScreen() fails in the following example, I lose 128 chip bytes. Because OpenScreen() is called twice, I end up losing 256. Any ideas on why? Is there a problem with OpenScreen(), or am I just being rather blind? (Note: Taking out the font assignment line doesn't help, and neither does running without morerows...) Ali Ozer, ali@rocky.stanford.edu ---------buggy code---------- struct TextAttr NormalFontDesc = {(STRPTR)"topaz.font", 8, 0, 0}; struct Screen *OpenPictureScreen (borderpen, detailpen, depth) int borderpen, detailpen, depth; { struct NewScreen ns; struct NewWindow nw; setmem (&ns, sizeof(ns), 0); setmem (&nw, sizeof(nw), 0); ns.DefaultTitle = (UBYTE *)PROGNAME; /* Some #define'ed string */ ns.Font = &NormalFontDesc; ns.Width = nw.Width = ((struct GfxBase *)GfxBase)->NormalDisplayColumns; ns.Height = nw.Height = ((struct GfxBase *)GfxBase)->NormalDisplayRows * 2; ns.DetailPen = nw.DetailPen = detailpen; ns.BlockPen = nw.BlockPen = borderpen; ns.Depth = depth; ns.Type = nw.Type = CUSTOMSCREEN; nw.Flags = SMART_REFRESH | BORDERLESS | BACKDROP | RMBTRAP | ACTIVATE; nw.IDCMPFlags = MOUSEBUTTONS | MOUSEMOVE | GADGETUP; ns.ViewModes = HIRES | LACE; if (nw.Screen = OpenScreen (&ns)) { if (OpenWindow (&nw)) return (nw.Screen); else CloseScreen (nw.Screen); } else { /* Try with a smaller screen and see if we can open that. */ ns.Width = nw.Width = 640; ns.Height = nw.Height = 400; if (nw.Screen = OpenScreen (&ns)) { if (OpenWindow (&nw)) return (nw.Screen); else CloseScreen (nw.Screen); } } return (NULL); }
jimm@amiga.UUCP (Jim Mackraz) (12/23/87)
:: If OpenScreen() fails because there is not enough memory for the screen raster, layer, or gadgets data structures, the colormap it has allocated is not freed. You can minimize the occurence of this by allocating your own bitmap and using custombitmap, but there are still some further allocations that can fail (none nearly as large, though). This bug will be eliminated in future releases. jimm -- Jim Mackraz, I and I Computing amiga!jimm BIX:jmackraz Opinions are my own. Comments regarding the Amiga operating system, and all others, are NOT to be taken as Commodore official policy.