From: Radical NetSurfer Newsgroups: comp.os.msdos.djgpp Subject: Re: Are THESE two statements EQUAL? Date: Thu, 29 Jun 2000 22:48:11 -0400 Message-ID: <9j2ols0u32mparptuk04fid732pc0o2ipv@4ax.com> References: <5t7klskbj285civf9serk693otnho6t5j0 AT 4ax DOT com> <7qmkls0k46jupmhklc5sqesf999hn7vmjl AT 4ax DOT com> <8F61A359BASINANUNUR AT 132 DOT 236 DOT 56 DOT 8> <8F626A568ASINANUNUR AT 132 DOT 236 DOT 56 DOT 8> <83u2ec9mxn DOT fsf AT mercury DOT bitbucket> X-Newsreader: Forte Agent 1.8/32.548 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.202.134.202 X-Original-NNTP-Posting-Host: 216.202.134.202 X-Trace: 29 Jun 2000 22:50:40 -0400, 216.202.134.202 Lines: 98 X-Original-NNTP-Posting-Host: 64.31.79.51 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This whole entire discussion was started, when I kept getting SEGFAULTS (what I called "core-dumps") What my projected needed (needs) is to be able to dynamically, on-the-fly, create an ARRAY of BITMAP*'s and an equal number of PALETTE's.... THEN to properly reference, and when done, of course, a convenient way to destroy them. Fortunately, for 1600x1200 screen modes, this comes to less than 4000 bitmaps (most of which are small, but all true color). and becuase my problems were DIRECTLY related to segment-faults, with DJGPP/Allegro specific packages, it seemed proper to expect that somebody would help me out... instead I get silly "you're being off topic" nonsense. Right now, this is whats being done: Globally: BITMAP **Pieces=NULL; //POINTER to an Array_of_Pointers to Bitmap's PALLETE *PPpal=NULL; //Pointer to an Array of Pallete's and then, int Allocanbc(int PUZ_SIZE) { int ALLOC_OK; ALLOC_OK = 0; [SNIP] if (Pieces = (BITMAP**)malloc(PUZ_SIZE * sizeof(BITMAP*)))==NULL ) { printf("ERROR: Unable to allocate Pieces Array\n"); exit(101); } else { ++ALLOC_OK; } if ( (PPpal = (PALLETE*)malloc(RIV_SIZE * sizeof(PALLETE)))==NULL ) { printf("ERROR: Unable to allocate Pieces Array\n"); exit(101); } else { ++ALLOC_OK; } if ( ALLOC_OK != 3 ) return (-1); else return (0); } //AllocPuzzle is this any good programming practice, or what? THANKS! Email always welcomed: radsmail AT juno DOT com http://members.tripod.com/~RadSurfer/ On 29 Jun 2000 14:50:28 -0700, Nate Eldredge wrote: >Sinan_Unur AT mail DOT com (A. Sinan Unur) writes: > >> as for BITMAP and PALLETE, all one should care about is the API >> through which you access these structures (that is the whole point >> why you are provided with a BITMAP data type rather than an array of >> int.) further, BITMAP and PALLETE are logically separate concepts >> regardless of any affinity that might exist between their underlying >> implementations. > >And in fact, there isn't any. > >typedef struct BITMAP /* a bitmap structure */ >{ > int w, h; /* width and height in pixels */ > int clip; /* flag if clipping is turned on */ > int cl, cr, ct, cb; /* clip left, right, top and bottom values */ > GFX_VTABLE *vtable; /* drawing functions */ > void (*write_bank)(); /* write bank selector, see bank.s */ > void (*read_bank)(); /* read bank selector, see bank.s */ > void *dat; /* the memory we allocated for the bitmap */ > int bitmap_id; /* for identifying sub-bitmaps */ > void *extra; /* points to a structure with more info */ > int line_ofs; /* line offset (for screen sub-bitmaps) */ > int seg; /* bitmap segment */ > unsigned char *line[0]; /* pointers to the start of each line */ >} BITMAP; > >vs. > >typedef struct RGB >{ > unsigned char r, g, b; > unsigned char filler; >} RGB; >typedef RGB PALLETE[PAL_SIZE]; > >No similarities whatever.