Re: DrawContext -- reports on self?
[email protected] Mon, 29 Aug 2011 04:13:10 +0000
| Newsgroups | gmane.comp.video.graphicsmagick.apis |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Aug 28, 2011 at 10:59:23PM -0500, Bob Friesenhahn wrote: > On Mon, 29 Aug 2011, [email protected] wrote: > >> How can I tell whether a DrawContext dc; type is allocated or not? The >> structure is described as opaque, and I see no reporting APIs that I >> can pass this to. > > This type is allocated by DrawAllocateContext(). It is a pointer-based > handle declared like: > > typedef struct _DrawContext *DrawContext; > > so > > if (dc != (DrawContext) NULL) > > or > > if (dc != 0) > > should work fine for determining if it was allocated already. Hrmm... so I should: DrawContext *dc; dc=DrawAllocateContext(); /* like this? */ I was having a tough time w/ leaks and core dumps w/ my various attempts... am currently: DrawContext dc; dc=DrawAllocateContext(); /* this is leak-free, crash-free */ but my tests: if(!dc) { // no draw context... } were not working like I expected. Comments? -bch > If DrawAllocateContext() fails to allocate the context structure > (indicating a serious problem) then the program will simply exit with a > fatal error. If one of the allocated members of the structure fails to > be allocated, then (DrawContext) NULL is returned, and an error message > is saved to image->exception. > > Bob > -- > Bob Friesenhahn > [email protected], http://www.simplesystems.org/users/bfriesen/ > GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ -- Brad Harder Method Logic Digital Consulting http://methodlogic.net/ http://twitter.com/bcharder ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev