maint: remove all uses of OF((...)) prototype-hiding macro
[gzip.git] / msdos / tailor.c
blob1d6d6ef4b2b63508ea164fadd2e2b0bc6f526682
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 */
7 /* tailor.c is a bunch of non portable routines.
8 * It should be kept to a minimum.
9 */
11 #include <config.h>
12 #include "tailor.h"
13 #include "gzip.h"
15 #ifdef __TURBOC__
17 /************************/
18 /* Function fcalloc() */
19 /************************/
21 /* Turbo C malloc() does not allow dynamic allocation of 64K bytes
22 * and farmalloc(64K) returns a pointer with an offset of 8, so we
23 * must fix the pointer. Warning: the pointer must be put back to its
24 * original form in order to free it, use fcfree().
25 * For MSC, use halloc instead of this function (see tailor.h).
27 static ush ptr_offset = 0;
29 void * fcalloc(items, size)
30 unsigned items; /* number of items */
31 unsigned size; /* item size */
33 void * buf = farmalloc((ulg)items*size + 16L);
34 if (buf == NULL) return NULL;
35 /* Normalize the pointer to seg:0 */
36 if (ptr_offset == 0) {
37 ptr_offset = (ush)((uch*)buf-0);
38 } else if (ptr_offset != (ush)((uch*)buf-0)) {
39 error(_("inconsistent ptr_offset"));
41 *((ush*)&buf+1) += (ptr_offset + 15) >> 4;
42 *(ush*)&buf = 0;
43 return buf;
46 void fcfree(ptr)
47 void *ptr; /* region allocated with fcalloc() */
49 /* Put the pointer back to its original form: */
50 *((ush*)&ptr+1) -= (ptr_offset + 15) >> 4;
51 *(ush*)&ptr = ptr_offset;
52 farfree(ptr);
55 #endif /* __TURBOC__ */