home *** CD-ROM | disk | FTP | other *** search
- LinkUmTmpRas()
- NAME
- InitLinkTR, UnlinkFreeTR, FreeTmpRas -- allocate-init-link a TmpRas into
- a rastport, and unlink-free a TmpRas from a rastport.
- (written for Manx C 3.4a long ints, large code and data)
- SYNTAX
- #include <exec/types.h>
- #include <graphics/rastport.h>
- #include <graphics/gfxbase.h>
- struct TmpRas *InitLinkTR(rastport, width, height, return_code)
- struct RastPort *rastport;
- LONG width,
- height,
- *return_code;
- LONG UnlinkFreeTR(rastport, width, height)
- struct RastPort *rastport;
- LONG width,
- height;
-
- LONG FreeTmpRas(tmpras, width, height)
- struct TmpRas *tmpras;
- LONG width,
- height;
- DESCRIPTION
- A set of three functions to allocate, init and link in TmpRas structures,
- and to unlink and free TmpRas structures.
- InitLinkTR() AllocMem()'s the storage for the TmpRas structure, and
- AllocRaster()'s a raster of the given width and height. It then
- InitTmpRas()'s the TmpRas struct with the raster, and links it into the
- given RastPort.
- To link it into the RastPort, it Forbid()'s, changes the RastPort to
- point to the new TmpRas structure, and then Permit()'s.
- It returns the pointer that was in the TmpRas field of the RastPort.
- The valid return codes from the return_code argument are:
- 0 == everything ok
- -1 == GfxBase not open -- nothing done
- -2 == can't allocate raster (not enough memory)
- -3 == can't allocate TmpRas structure (not enough memory)
- UnlinkFreeTR() first Forbid()'s, unlinks the TmpRas struct in the RastPort
- setting the ponter to NULL, and then Permit()'s again.
- Next, it calls FreeTmpRas() to free the TmpRas and raster passing on the
- width and height.
- The valid return codes (from the function itself) are:
- 0 == everything ok
- -1 == GfxBase not open -- nothing done
- -2 == FreeTmpRas() failed
- FreeTmpRas() checks if the TmpRas pointer is NULL, if so, it returns -2.
- If the TmpRas pointer is not NULL, it frees the raster by calling
- FreeRaster() using the height and width as the height and width of the
- raster, and then calls FreeMem on the TmpRas structure itself.
- The valid return codes are:
- 0 == everything ok
- -2 == TmpRas pointer NULL -- nothing done
- NOTES
- FreeTmpRas can be used on the pointer returned by InitLinkTR() provided
- it was allocated in a manner similar to the way InitLinkTR() does, and
- the width and height are correct for the raster being freed.
- Screens and windows have separate RastPorts, so linking a TmpRas structure
- into one while using the other for rendering will always solicit a visit
- from the GURU.
- I'm not sure Forbid()'s and Permit()'s need be in these functions, but
- they seemed like a reasonable precaution on a multitasking machine.
- BUGS
- FreeTmpRas() assumes that the raster and TmpRas struct were allocated
- using AllocRaster() and AllocMem() respectively. If this is not the case
- the machine will most likely GURU.
- If UnlinkFreeTR() or FreeTmpRas() are not called on the TmpRas struct
- allocated by InitLinkTR(), the memory will be lost when the program
- ends (ie. you won't be able to get the memory back without rebooting).
- Changing the width and height arguments between calls to InitLinkTR() and,
- UnlinkFreeTR() or FreeTmpRas() will result in bad things happening
- (GURUs?).
- The width and height of the raster should be made as large as the screen
- or window will ever be -- I'm not sure what will happen if the screen or
- window is made larger after the raster is allocated, but I suspect GURUs.
- SEE ALSO
- AllocMem(), AllocRaster(), FreeRaster(), FreeMem(), InitTmpRas(),
- Forbid(), Permit(), OpenLibrary(), graphics.library
-