/***************************************************************** * flalfb.c: FBM Release 1.0 25-Feb-90 Michael Mauldin * * Copyright (C) 1989,1990 by Michael Mauldin. Permission is granted * to use this file in whole or in part for any purpose, educational, * recreational or commercial, provided that this copyright notice * is retained unchanged. This software is available to all free of * charge by anonymous FTP and in the UUNET archives. * * flalfb.c: Fuzzy bitmap allocation * * CONTENTS * alloc_fbm (image) * free_fbm (image) * * EDITLOG * LastEditDate = Mon Jun 25 00:04:43 1990 - Michael Mauldin * LastFileName = /usr2/mlm/src/misc/fbm/flalfb.c * * HISTORY * 25-Jun-90 Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon * Package for Release 1.0 * * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University * Beta release (version 0.9) mlm@cs.cmu.edu * * 12-Nov-88 Michael Mauldin (mlm) at Carnegie-Mellon University * Created. *****************************************************************/ # include # include # include # include "fbm.h" /**************************************************************** * alloc_fbm: Allocate enough bytes for the bitmap and colormap * of an image where the header has already been filled in. ****************************************************************/ #ifndef lint static char *fbmid = "$FBM flalfb.c <1.0> 25-Jun-90 (C) 1989,1990 by Michael Mauldin, source \ code available free from MLM@CS.CMU.EDU and from UUNET archives$"; #endif alloc_fbm (image) FBM *image; { unsigned bmsize, cmsize; if (! free_fbm (image)) return (0); /* Calculate bytes needed */ bmsize = (image->hdr.planes * image->hdr.plnlen); cmsize = image->hdr.clrlen; if (! (image->bm = (unsigned char *) malloc (bmsize)) || (cmsize && ! (image->cm = (unsigned char *) malloc (cmsize)))) { perror ("alloc_fbm"); exit (1); } return (1); } /**************************************************************** * free_fbm: Free the storage allocate by alloc_fbm ****************************************************************/ free_fbm (image) FBM *image; { if (image->bm) { free ((char *) image->bm); image->bm = (unsigned char *) NULL; } if (image->cm) { free ((char *) image->cm); image->cm = (unsigned char *) NULL; } return (1); }