home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / btnlib / util.c < prev   
C/C++ Source or Header  |  1990-04-20  |  2KB  |  49 lines

  1. #ifndef lint
  2. static char SccsId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /*
  6.  * Module:    util.c (Utility Functions)
  7.  * Project:    PROS -- ROSAT RSDC
  8.  * Purpose:    A calloc with error checking that every library needs
  9.  * Subroutines:    btn_Alloc()            returns: char *
  10.  * Xlib calls:    none
  11.  * Copyright:    1989 Smithsonian Astrophysical Observatory
  12.  *        You may do anything you like with this file except remove
  13.  *        this copyright.  The Smithsonian Astrophysical Observatory
  14.  *        makes no representations about the suitability of this
  15.  *        software for any purpose.  It is provided "as is" without
  16.  *        express or implied warranty.
  17.  * Modified:    {0} Michael VanHilst    initial version        18 March 1989
  18.  *        {n} <who> -- <does what> -- <when>
  19.  */
  20.  
  21. #include <stdio.h>    /* define stderr, NULL */
  22.  
  23. /*
  24.  * Subroutine:    btn_Alloc
  25.  * Purpose:    calloc with printf'less error message and exit for failure
  26.  * Returns:    char pointer to allocated and cleared space
  27.  * Called by:    MakeButtonBox(), btn_LabelButtons() in MakeBtnBox.c
  28.  * Called by:    btn_MakeXImages() in MakeXImage.c
  29.  * Xlib calls:    none
  30.  * Post-state:    space allocated on aligned boundary and zeroed
  31.  * Note:    printf does malloc so don't use it to report a malloc failure
  32.  */
  33. static char *errnote = " allocation failure\n";
  34. char *btn_Alloc ( count, size, errmess )
  35.      int count;
  36.      unsigned int size;
  37.      char *errmess;
  38. {
  39.   char *space;
  40.   char *calloc();
  41.  
  42.   if( (space = (char *)calloc((unsigned)count, size)) == NULL ) {
  43.     fputs(errmess, stderr);
  44.     fputs(errnote, stderr);
  45.     exit( 0 );
  46.   }
  47.   return( space );
  48. }
  49.