diff options
Diffstat (limited to '')
| -rw-r--r-- | zutil.c | 43 |
1 files changed, 23 insertions, 20 deletions
| @@ -38,8 +38,8 @@ void z_error (m) | |||
| 38 | #ifndef HAVE_MEMCPY | 38 | #ifndef HAVE_MEMCPY |
| 39 | 39 | ||
| 40 | void zmemcpy(dest, source, len) | 40 | void zmemcpy(dest, source, len) |
| 41 | Byte* dest; | 41 | Bytef* dest; |
| 42 | Byte* source; | 42 | Bytef* source; |
| 43 | uInt len; | 43 | uInt len; |
| 44 | { | 44 | { |
| 45 | if (len == 0) return; | 45 | if (len == 0) return; |
| @@ -49,7 +49,7 @@ void zmemcpy(dest, source, len) | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | void zmemzero(dest, len) | 51 | void zmemzero(dest, len) |
| 52 | Byte* dest; | 52 | Bytef* dest; |
| 53 | uInt len; | 53 | uInt len; |
| 54 | { | 54 | { |
| 55 | if (len == 0) return; | 55 | if (len == 0) return; |
| @@ -59,8 +59,10 @@ void zmemzero(dest, len) | |||
| 59 | } | 59 | } |
| 60 | #endif | 60 | #endif |
| 61 | 61 | ||
| 62 | #if defined(__TURBOC__) && !defined(__SMALL__) | 62 | #if defined( __TURBOC__) && !defined(__SMALL__) && !defined(__MEDIUM__) |
| 63 | 63 | /* Small and medium model are for now limited to near allocation with | |
| 64 | * reduced MAX_WBITS and MAX_MEM_LEVEL | ||
| 65 | */ | ||
| 64 | # define MY_ZCALLOC | 66 | # define MY_ZCALLOC |
| 65 | 67 | ||
| 66 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes | 68 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
| @@ -75,8 +77,8 @@ void zmemzero(dest, len) | |||
| 75 | local int next_ptr = 0; | 77 | local int next_ptr = 0; |
| 76 | 78 | ||
| 77 | typedef struct ptr_table_s { | 79 | typedef struct ptr_table_s { |
| 78 | voidp org_ptr; | 80 | voidpf org_ptr; |
| 79 | voidp new_ptr; | 81 | voidpf new_ptr; |
| 80 | } ptr_table; | 82 | } ptr_table; |
| 81 | 83 | ||
| 82 | local ptr_table table[MAX_PTR]; | 84 | local ptr_table table[MAX_PTR]; |
| @@ -87,9 +89,9 @@ local ptr_table table[MAX_PTR]; | |||
| 87 | * a protected system like OS/2. Use Microsoft C instead. | 89 | * a protected system like OS/2. Use Microsoft C instead. |
| 88 | */ | 90 | */ |
| 89 | 91 | ||
| 90 | voidp zcalloc (voidp opaque, unsigned items, unsigned size) | 92 | voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) |
| 91 | { | 93 | { |
| 92 | voidp buf = opaque; /* just to make some compilers happy */ | 94 | voidpf buf = opaque; /* just to make some compilers happy */ |
| 93 | ulg bsize = (ulg)items*size; | 95 | ulg bsize = (ulg)items*size; |
| 94 | 96 | ||
| 95 | if (bsize < 65536L) { | 97 | if (bsize < 65536L) { |
| @@ -108,7 +110,7 @@ voidp zcalloc (voidp opaque, unsigned items, unsigned size) | |||
| 108 | return buf; | 110 | return buf; |
| 109 | } | 111 | } |
| 110 | 112 | ||
| 111 | void zcfree (voidp opaque, voidp ptr) | 113 | void zcfree (voidpf opaque, voidpf ptr) |
| 112 | { | 114 | { |
| 113 | int n; | 115 | int n; |
| 114 | if (*(ush*)&ptr != 0) { /* object < 64K */ | 116 | if (*(ush*)&ptr != 0) { /* object < 64K */ |
| @@ -131,7 +133,8 @@ void zcfree (voidp opaque, voidp ptr) | |||
| 131 | } | 133 | } |
| 132 | #endif /* __TURBOC__ */ | 134 | #endif /* __TURBOC__ */ |
| 133 | 135 | ||
| 134 | #if defined(MSDOS) && !defined(__TURBOC__) /* MSC */ | 136 | #if defined(M_I86SM)||defined(M_I86MM)||defined(M_I86CM)||defined(M_I86LM) |
| 137 | /* Microsoft C */ | ||
| 135 | 138 | ||
| 136 | # define MY_ZCALLOC | 139 | # define MY_ZCALLOC |
| 137 | 140 | ||
| @@ -140,13 +143,13 @@ void zcfree (voidp opaque, voidp ptr) | |||
| 140 | # define _hfree hfree | 143 | # define _hfree hfree |
| 141 | #endif | 144 | #endif |
| 142 | 145 | ||
| 143 | voidp zcalloc (voidp opaque, unsigned items, unsigned size) | 146 | voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) |
| 144 | { | 147 | { |
| 145 | if (opaque) opaque = 0; /* to make compiler happy */ | 148 | if (opaque) opaque = 0; /* to make compiler happy */ |
| 146 | return _halloc((long)items, size); | 149 | return _halloc((long)items, size); |
| 147 | } | 150 | } |
| 148 | 151 | ||
| 149 | void zcfree (voidp opaque, voidp ptr) | 152 | void zcfree (voidpf opaque, voidpf ptr) |
| 150 | { | 153 | { |
| 151 | if (opaque) opaque = 0; /* to make compiler happy */ | 154 | if (opaque) opaque = 0; /* to make compiler happy */ |
| 152 | _hfree(ptr); | 155 | _hfree(ptr); |
| @@ -158,21 +161,21 @@ void zcfree (voidp opaque, voidp ptr) | |||
| 158 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ | 161 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
| 159 | 162 | ||
| 160 | #ifndef __GO32__ | 163 | #ifndef __GO32__ |
| 161 | extern voidp calloc OF((uInt items, uInt size)); | 164 | extern voidp calloc OF((uInt items, uInt size)); |
| 162 | extern void free OF((voidp ptr)); | 165 | extern void free OF((voidpf ptr)); |
| 163 | #endif | 166 | #endif |
| 164 | 167 | ||
| 165 | voidp zcalloc (opaque, items, size) | 168 | voidpf zcalloc (opaque, items, size) |
| 166 | voidp opaque; | 169 | voidpf opaque; |
| 167 | unsigned items; | 170 | unsigned items; |
| 168 | unsigned size; | 171 | unsigned size; |
| 169 | { | 172 | { |
| 170 | return calloc(items, size); | 173 | return (voidpf)calloc(items, size); |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | void zcfree (opaque, ptr) | 176 | void zcfree (opaque, ptr) |
| 174 | voidp opaque; | 177 | voidpf opaque; |
| 175 | voidp ptr; | 178 | voidpf ptr; |
| 176 | { | 179 | { |
| 177 | free(ptr); | 180 | free(ptr); |
| 178 | } | 181 | } |
