home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / compress / gnuzip_.zip / TAILOR.C < prev    next >
C/C++ Source or Header  |  1993-03-28  |  1KB  |  42 lines

  1. /* tailor.c -- target dependent functions
  2.  * Copyright (C) 1992-1993 Jean-loup Gailly
  3.  * This is free software; you can redistribute it and/or modify it under the
  4.  * terms of the GNU General Public License, see the file COPYING.
  5.  */
  6.  
  7. /* tailor.c is a bunch of non portable routines.
  8.  * It should be kept to a minimum.
  9.  */
  10.  
  11. #include "tailor.h"
  12. #include "gzip.h"
  13.  
  14. #ifndef lint
  15. static char rcsid[] = "$Id: tailor.c,v 0.7 1993/01/26 19:15:23 jloup Exp $";
  16. #endif
  17.  
  18. #ifdef __TURBOC__
  19.  
  20. /************************/
  21. /*  Function fcalloc()  */
  22. /************************/
  23.  
  24. /* Turbo C malloc() does not allow dynamic allocation of 64K bytes
  25.  * and farmalloc(64K) returns a pointer with an offset of 8, so we
  26.  * must fix the pointer. Warning: the pointer must be put back to its
  27.  * original form in order to free it.
  28.  * For MSC, use halloc instead of this function (see tailor.h).
  29.  */
  30. void * fcalloc(items, size)
  31.     unsigned items; /* number of items */
  32.     unsigned size;  /* item size */
  33. {
  34.     void * buf = farmalloc((ulg)items*size + 16L);
  35.     /* Normalize the pointer to seg:0 */
  36.     *((int*)&buf+1) += ((unsigned)((uch*)buf-0) + 15) >> 4;
  37.     *(int*)&buf = 0;
  38.     return buf; /* buf stays NULL if alloc failed */
  39. }
  40.  
  41. #endif /* __TURBOC__ */
  42.