vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #include <asn_internal.h> |
| 6 | #include <per_support.h> |
| 7 | #include <constr_TYPE.h> |
| 8 | #include <per_opentype.h> |
| 9 | |
| 10 | typedef struct uper_ugot_key { |
| 11 | asn_per_data_t oldpd; /* Old per data source */ |
| 12 | size_t unclaimed; |
| 13 | size_t ot_moved; /* Number of bits moved by OT processing */ |
| 14 | int repeat; |
| 15 | } uper_ugot_key; |
| 16 | |
| 17 | static int uper_ugot_refill(asn_per_data_t *pd); |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 18 | static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); |
| 19 | static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 20 | |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 21 | int asn_debug_indent; |
| 22 | |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 23 | /* |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 24 | * Encode an "open type field". |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 25 | * #10.1, #10.2 |
| 26 | */ |
| 27 | int |
| 28 | uper_open_type_put(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { |
| 29 | void *buf; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 30 | void *bptr; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 31 | ssize_t size; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 32 | size_t toGo; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 33 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 34 | ASN_DEBUG("Open type put %s ...", td->name); |
| 35 | |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 36 | size = uper_encode_to_new_buffer(td, constraints, sptr, &buf); |
| 37 | if(size <= 0) return -1; |
| 38 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 39 | for(bptr = buf, toGo = size; toGo;) { |
| 40 | ssize_t maySave = uper_put_length(po, toGo); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 41 | if(maySave < 0) break; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 42 | if(per_put_many_bits(po, bptr, maySave * 8)) break; |
| 43 | bptr = (char *)bptr + maySave; |
| 44 | toGo -= maySave; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 45 | } |
| 46 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 47 | FREEMEM(buf); |
| 48 | if(toGo) return -1; |
| 49 | |
| 50 | ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", |
| 51 | td->name, size); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 56 | static asn_dec_rval_t |
| 57 | uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, |
| 58 | asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { |
| 59 | asn_dec_rval_t rv; |
| 60 | ssize_t chunk_bytes; |
| 61 | int repeat; |
| 62 | uint8_t *buf = 0; |
| 63 | size_t bufLen = 0; |
| 64 | size_t bufSize = 0; |
| 65 | asn_per_data_t spd; |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 66 | size_t padding; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 67 | |
| 68 | _ASN_STACK_OVERFLOW_CHECK(ctx); |
| 69 | |
vlm | 36fc702 | 2007-06-29 11:32:25 +0000 | [diff] [blame] | 70 | ASN_DEBUG("Getting open type %s...", td->name); |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 71 | |
| 72 | do { |
| 73 | chunk_bytes = uper_get_length(pd, -1, &repeat); |
| 74 | if(chunk_bytes < 0) { |
| 75 | FREEMEM(buf); |
| 76 | _ASN_DECODE_STARVED; |
| 77 | } |
| 78 | if(bufLen + chunk_bytes > bufSize) { |
| 79 | void *ptr; |
| 80 | bufSize = chunk_bytes + (bufSize << 2); |
| 81 | ptr = REALLOC(buf, bufSize); |
| 82 | if(!ptr) { |
| 83 | FREEMEM(buf); |
| 84 | _ASN_DECODE_FAILED; |
| 85 | } |
| 86 | buf = ptr; |
| 87 | } |
| 88 | if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) { |
| 89 | FREEMEM(buf); |
| 90 | _ASN_DECODE_STARVED; |
| 91 | } |
| 92 | bufLen += chunk_bytes; |
| 93 | } while(repeat); |
| 94 | |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 95 | ASN_DEBUG("Getting open type %s encoded in %d bytes", td->name, |
| 96 | bufLen); |
| 97 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 98 | memset(&spd, 0, sizeof(spd)); |
| 99 | spd.buffer = buf; |
| 100 | spd.nbits = bufLen << 3; |
| 101 | |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 102 | asn_debug_indent += 4; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 103 | rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 104 | asn_debug_indent -= 4; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 105 | |
vlm | a0a8e7c | 2007-06-29 17:33:04 +0000 | [diff] [blame^] | 106 | if(rv.code == RC_OK) { |
| 107 | /* Check padding validity */ |
| 108 | padding = spd.nbits - spd.nboff; |
| 109 | if(padding < 8 && per_get_few_bits(&spd, padding) == 0) { |
| 110 | /* Everything is cool */ |
| 111 | FREEMEM(buf); |
| 112 | return rv; |
| 113 | } |
| 114 | FREEMEM(buf); |
| 115 | if(padding >= 8) { |
| 116 | ASN_DEBUG("Too large padding %d in open type", padding); |
| 117 | _ASN_DECODE_FAILED; |
| 118 | } else { |
| 119 | ASN_DEBUG("Non-zero padding"); |
| 120 | _ASN_DECODE_FAILED; |
| 121 | } |
| 122 | } else { |
| 123 | FREEMEM(buf); |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 124 | } |
| 125 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 126 | return rv; |
| 127 | } |
| 128 | |
| 129 | static asn_dec_rval_t GCC_NOTUSED |
| 130 | uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 131 | asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { |
| 132 | uper_ugot_key arg; |
| 133 | asn_dec_rval_t rv; |
| 134 | ssize_t padding; |
| 135 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 136 | _ASN_STACK_OVERFLOW_CHECK(ctx); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 137 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 138 | ASN_DEBUG("Getting open type %s from %s", td->name, |
| 139 | per_data_string(pd)); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 140 | arg.oldpd = *pd; |
| 141 | arg.unclaimed = 0; |
| 142 | arg.ot_moved = 0; |
| 143 | arg.repeat = 1; |
| 144 | pd->refill = uper_ugot_refill; |
| 145 | pd->refill_key = &arg; |
| 146 | pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */ |
| 147 | pd->moved = 0; /* This now counts the open type size in bits */ |
| 148 | |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 149 | asn_debug_indent += 4; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 150 | rv = td->uper_decoder(ctx, td, constraints, sptr, pd); |
vlm | 39422fb | 2007-06-29 11:25:49 +0000 | [diff] [blame] | 151 | asn_debug_indent -= 4; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 152 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 153 | #define UPDRESTOREPD do { \ |
| 154 | /* buffer and nboff are valid, preserve them. */ \ |
| 155 | pd->nbits = arg.oldpd.nbits - (pd->moved - arg.ot_moved); \ |
| 156 | pd->moved = arg.oldpd.moved + (pd->moved - arg.ot_moved); \ |
| 157 | pd->refill = arg.oldpd.refill; \ |
| 158 | pd->refill_key = arg.oldpd.refill_key; \ |
| 159 | } while(0) |
| 160 | |
| 161 | if(rv.code != RC_OK) { |
| 162 | UPDRESTOREPD; |
| 163 | return rv; |
| 164 | } |
| 165 | |
| 166 | ASN_DEBUG("OpenType %s pd%s old%s unclaimed=%d, repeat=%d" |
| 167 | , td->name, |
| 168 | per_data_string(pd), |
| 169 | per_data_string(&arg.oldpd), |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 170 | arg.unclaimed, arg.repeat); |
| 171 | |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 172 | padding = pd->moved % 8; |
| 173 | if(padding) { |
| 174 | int32_t pvalue; |
| 175 | if(padding > 7) { |
| 176 | ASN_DEBUG("Too large padding %d in open type", |
| 177 | padding); |
| 178 | rv.code = RC_FAIL; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 179 | UPDRESTOREPD; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 180 | return rv; |
| 181 | } |
| 182 | padding = 8 - padding; |
| 183 | ASN_DEBUG("Getting padding of %d bits", padding); |
| 184 | pvalue = per_get_few_bits(pd, padding); |
| 185 | switch(pvalue) { |
| 186 | case -1: |
| 187 | ASN_DEBUG("Padding skip failed"); |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 188 | UPDRESTOREPD; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 189 | _ASN_DECODE_STARVED; |
| 190 | case 0: break; |
| 191 | default: |
| 192 | ASN_DEBUG("Non-blank padding (%d bits 0x%02x)", |
vlm | 3dc56b9 | 2007-06-29 16:01:51 +0000 | [diff] [blame] | 193 | padding, (int)pvalue); |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 194 | UPDRESTOREPD; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 195 | _ASN_DECODE_FAILED; |
| 196 | } |
| 197 | } |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 198 | if(pd->nboff != pd->nbits) { |
| 199 | ASN_DEBUG("Open type %s overhead pd%s old%s", td->name, |
| 200 | per_data_string(pd), per_data_string(&arg.oldpd)); |
| 201 | if(1) { |
| 202 | UPDRESTOREPD; |
| 203 | _ASN_DECODE_FAILED; |
| 204 | } else { |
| 205 | arg.unclaimed += pd->nbits - pd->nboff; |
| 206 | } |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /* Adjust pd back so it points to original data */ |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 210 | UPDRESTOREPD; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 211 | |
| 212 | /* Skip data not consumed by the decoder */ |
| 213 | if(arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed); |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 214 | if(arg.unclaimed) { |
| 215 | switch(per_skip_bits(pd, arg.unclaimed)) { |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 216 | case -1: |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 217 | ASN_DEBUG("Claim of %d failed", arg.unclaimed); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 218 | _ASN_DECODE_STARVED; |
| 219 | case 0: |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 220 | ASN_DEBUG("Got claim of %d", arg.unclaimed); |
| 221 | break; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 222 | default: |
| 223 | /* Padding must be blank */ |
| 224 | ASN_DEBUG("Non-blank unconsumed padding"); |
| 225 | _ASN_DECODE_FAILED; |
| 226 | } |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 227 | arg.unclaimed = 0; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 228 | } |
| 229 | |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 230 | if(arg.repeat) { |
| 231 | ASN_DEBUG("Not consumed the whole thing"); |
| 232 | rv.code = RC_FAIL; |
| 233 | return rv; |
| 234 | } |
| 235 | |
| 236 | return rv; |
| 237 | } |
| 238 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 239 | |
| 240 | asn_dec_rval_t |
| 241 | uper_open_type_get(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, |
| 242 | asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { |
| 243 | |
| 244 | return uper_open_type_get_simple(ctx, td, constraints, |
| 245 | sptr, pd); |
| 246 | |
| 247 | } |
| 248 | |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 249 | int |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 250 | uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 251 | asn_TYPE_descriptor_t s_td; |
| 252 | asn_dec_rval_t rv; |
| 253 | |
| 254 | s_td.name = "<unknown extension>"; |
| 255 | s_td.uper_decoder = uper_sot_suck; |
| 256 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 257 | rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 258 | if(rv.code != RC_OK) |
| 259 | return -1; |
| 260 | else |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | /* |
| 265 | * Internal functions. |
| 266 | */ |
| 267 | |
| 268 | static asn_dec_rval_t |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 269 | uper_sot_suck(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 270 | asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { |
| 271 | asn_dec_rval_t rv; |
| 272 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 273 | (void)ctx; |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 274 | (void)td; |
| 275 | (void)constraints; |
| 276 | (void)sptr; |
| 277 | |
| 278 | while(per_get_few_bits(pd, 24) >= 0); |
| 279 | |
| 280 | rv.code = RC_OK; |
| 281 | rv.consumed = pd->moved; |
| 282 | |
| 283 | return rv; |
| 284 | } |
| 285 | |
| 286 | static int |
| 287 | uper_ugot_refill(asn_per_data_t *pd) { |
| 288 | uper_ugot_key *arg = pd->refill_key; |
| 289 | ssize_t next_chunk_bytes, next_chunk_bits; |
| 290 | ssize_t avail; |
| 291 | |
| 292 | asn_per_data_t *oldpd = &arg->oldpd; |
| 293 | |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 294 | ASN_DEBUG("REFILLING pd->moved=%d, oldpd->moved=%d", |
| 295 | pd->moved, oldpd->moved); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 296 | |
| 297 | /* Advance our position to where pd is */ |
| 298 | oldpd->buffer = pd->buffer; |
| 299 | oldpd->nboff = pd->nboff; |
| 300 | oldpd->nbits -= pd->moved - arg->ot_moved; |
| 301 | oldpd->moved += pd->moved - arg->ot_moved; |
| 302 | arg->ot_moved = pd->moved; |
| 303 | |
| 304 | if(arg->unclaimed) { |
| 305 | /* Refill the container */ |
| 306 | if(per_get_few_bits(oldpd, 1)) |
| 307 | return -1; |
| 308 | if(oldpd->nboff == 0) { |
| 309 | assert(0); |
| 310 | return -1; |
| 311 | } |
| 312 | pd->buffer = oldpd->buffer; |
| 313 | pd->nboff = oldpd->nboff - 1; |
| 314 | pd->nbits = oldpd->nbits; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 315 | ASN_DEBUG("UNCLAIMED <- return from (pd->moved=%d)", pd->moved); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 316 | return 0; |
| 317 | } |
| 318 | |
| 319 | if(!arg->repeat) { |
| 320 | ASN_DEBUG("Want more but refill doesn't have it"); |
| 321 | return -1; |
| 322 | } |
| 323 | |
| 324 | next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat); |
| 325 | ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d", |
| 326 | next_chunk_bytes, oldpd->moved, arg->repeat); |
| 327 | if(next_chunk_bytes < 0) return -1; |
| 328 | if(next_chunk_bytes == 0) { |
| 329 | pd->refill = 0; /* No more refills, naturally */ |
| 330 | assert(!arg->repeat); /* Implementation guarantee */ |
| 331 | } |
| 332 | next_chunk_bits = next_chunk_bytes << 3; |
| 333 | avail = oldpd->nbits - oldpd->nboff; |
| 334 | if(avail >= next_chunk_bits) { |
| 335 | pd->nbits = oldpd->nboff + next_chunk_bits; |
| 336 | arg->unclaimed = 0; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 337 | ASN_DEBUG("!+Parent frame %d bits, alloting %d [%d..%d] (%d)", |
| 338 | next_chunk_bits, oldpd->moved, |
| 339 | oldpd->nboff, oldpd->nbits, |
| 340 | oldpd->nbits - oldpd->nboff); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 341 | } else { |
| 342 | pd->nbits = oldpd->nbits; |
| 343 | arg->unclaimed = next_chunk_bits - avail; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 344 | ASN_DEBUG("!-Parent frame %d, require %d, will claim %d", avail, next_chunk_bits, arg->unclaimed); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 345 | } |
| 346 | pd->buffer = oldpd->buffer; |
| 347 | pd->nboff = oldpd->nboff; |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 348 | ASN_DEBUG("Refilled pd%s old%s", |
| 349 | per_data_string(pd), per_data_string(oldpd)); |
vlm | 5d3db2f | 2007-06-27 04:09:37 +0000 | [diff] [blame] | 350 | return 0; |
| 351 | } |
vlm | b08408b | 2007-06-29 02:28:50 +0000 | [diff] [blame] | 352 | |
| 353 | static int |
| 354 | per_skip_bits(asn_per_data_t *pd, int skip_nbits) { |
| 355 | int hasNonZeroBits = 0; |
| 356 | while(skip_nbits > 0) { |
| 357 | int skip; |
| 358 | if(skip_nbits < skip) |
| 359 | skip = skip_nbits; |
| 360 | else |
| 361 | skip = 24; |
| 362 | skip_nbits -= skip; |
| 363 | |
| 364 | switch(per_get_few_bits(pd, skip)) { |
| 365 | case -1: return -1; /* Starving */ |
| 366 | case 0: continue; /* Skipped empty space */ |
| 367 | default: hasNonZeroBits = 1; continue; |
| 368 | } |
| 369 | } |
| 370 | return hasNonZeroBits; |
| 371 | } |