/* Check properties of malloced chunks at the point they are malloced
556988
private void checkMallocedChunk(int mem, int s) {
    if (VALIDATING) {
      int p = memToChunk(mem);
      int sz = head(p) & ~INUSE_BITS;
      checkInUseChunk(p);
      if (sz < MIN_CHUNK_SIZE) 
        throw new AssertionError("Allocated chunk " + p + " is too small");
      if ((sz & CHUNK_ALIGN_MASK) != 0)
        throw new AssertionError("Chunk size " + sz + " of " + p + " is not correctly aligned");
      if (sz < s)
        throw new AssertionError("Allocated chunk " + p + " is smaller than requested [" + sz + "<" + s + "]");
      if (sz > (s + MIN_CHUNK_SIZE)) {
        throw new AssertionError("Allocated chunk " + p + " is too large (should have been split off) [" + sz + ">>" + s + "]");
      }
    }
  }
146173
function chunkArray(myArray, chunk_size){
    var results = [];

    while (myArray.length) {
      results.push(myArray.splice(0, chunk_size));
    }

    return results;
  }
463546
private void checkFreeChunk(int p) {
    if (VALIDATING) {
      int sz = chunkSize(p);
      int next = p + sz;
      checkAnyChunk(p);
      if (isInUse(p))
        throw new AssertionError("Free chunk " + p + " is not marked as free");
      if (nextPreviousInUse(p))
        throw new AssertionError("Next chunk after " + p + " has it marked as in use");
      if (p != designatedVictim && p != top) {
        if (sz < MIN_CHUNK_SIZE) 
          throw new AssertionError("Free chunk " + p + " is too small");
        if ((sz & CHUNK_ALIGN_MASK) != 0)
          throw new AssertionError("Chunk size " + sz + " of " + p + " is not correctly aligned");
        if (!isAligned(chunkToMem(p)))
          throw new AssertionError("User pointer for chunk " + p + " is not correctly aligned");
        if (prevFoot(next) != sz)
          throw new AssertionError("Next chunk after " + p + " has an incorrect previous size");
        if (!previousInUse(p))
          throw new AssertionError("Chunk before free chunk " + p + " is free - should have been merged");
        if (next != top && !isInUse(next))
          throw new AssertionError("Chunk after free chunk " + p + " is free - should have been merged");        
        if (backward(forward(p)) != p)
          throw new AssertionError("Free chunk " + p + " has invalid chain links");
        if (forward(backward(p)) != p)
          throw new AssertionError("Free chunk " + p + " has invalid chain links");
      }
    }
  }
776908
def _check_pointers(parser):
    """"""
    from fortpy.stats.bp import check_pointers
    check_pointers(parser, args["source"], args["filter"], args["recursive"])
579822
function blockChecksums(fs, path, size, callback) {
  var cache = {};

  fs.readFile(path, function (err, data) {
    if (!err) {
      // cache file
      cache[path] = data;
    } else if (err && err.code === 'ENOENT') {
      cache[path] = [];
    } else {
      return callback(err);
    }

    var length = cache[path].length;
    var incr = size;
    var start = 0;
    var end = incr > length ? length : incr;
    var blockIndex = 0;
    var result = [];
    var chunk;
    var weak;
    var strong;

    while (start < length) {
      chunk  = cache[path].slice(start, end);
      weak   = calcWeak32(chunk).sum;
      strong = md5sum(chunk);

      result.push({
        index: blockIndex,
        weak: weak,
        strong: strong
      });
      // update slice indices
      start += incr;
      end = (end + incr) > length ? length : end + incr;
      // update block index
      blockIndex++;
    }

    callback(null, result);
  });
}
889387
private boolean findFreeChunk(long x) {
    long size = chunkSize(x);
    if (isSmall(size)) {
      int sidx = smallBinIndex(size);
      long h = smallBins[sidx];
      if (smallMapIsMarked(sidx)) {
        long p = h;
        do {
          if (p == x)
            return true;
        } while ((p = forward(p)) != h);
      }
    } else {
      int tidx = treeBinIndex(size);
      if (treeMapIsMarked(tidx)) {
        long t = treeBins[tidx];
        long sizebits = size << leftShiftForTreeIndex(tidx);
        while (t != -1L && chunkSize(t) != size) {
          t = child(t, (int) ((sizebits >>> (SIZE_T_BITSIZE - 1)) & 1));
          sizebits <<= 1;
        }
        if (t != -1L) {
          long u = t;
          do {
            if (u == x)
              return true;
          } while ((u = forward(u)) != t);
        }
      }
    }
    return false;
  }
871272
def async_stmt_check(self, original, loc, tokens):
        """"""
        return self.check_py("35", "async for/with", original, loc, tokens)
1329316
def read_chunked(self):
        """"""
        self._load_metadata()
        for i in range(self.npartitions):
            yield self._get_partition(i)
1157424
function checkLastSegment(node) {
            let loc, name;

            /*
             * Skip if it expected no return value or unreachable.
             * When unreachable, all paths are returned or thrown.
             */
            if (!funcInfo.hasReturnValue ||
                funcInfo.codePath.currentSegments.every(isUnreachable) ||
                astUtils.isES5Constructor(node) ||
                isClassConstructor(node)
            ) {
                return;
            }

            // Adjust a location and a message.
            if (node.type === "Program") {

                // The head of program.
                loc = { line: 1, column: 0 };
                name = "program";
            } else if (node.type === "ArrowFunctionExpression") {

                // `=>` token
                loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
            } else if (
                node.parent.type === "MethodDefinition" ||
                (node.parent.type === "Property" && node.parent.method)
            ) {

                // Method name.
                loc = node.parent.key.loc.start;
            } else {

                // Function name or `function` keyword.
                loc = (node.id || node).loc.start;
            }

            if (!name) {
                name = astUtils.getFunctionNameWithKind(node);
            }

            // Reports.
            context.report({
                node,
                loc,
                messageId: "missingReturn",
                data: { name }
            });
        }
1047790
function __getLengthByArrayBuffers(data) {
	let length = 0;
	for (let key in data) {
		length += data[key].byteLength;
	}
	return length;
}
147486
def _is_contiguous(positions):
    """"""
    previous = positions[0]
    for current in positions[1:]:
        if current != previous + 1:
            return False
        previous = current
    return True
149590
function checkSpacingForForOfStatement(node) {
            if (node.await) {
                checkSpacingBefore(sourceCode.getFirstToken(node, 0));
                checkSpacingAfter(sourceCode.getFirstToken(node, 1));
            } else {
                checkSpacingAroundFirstToken(node);
            }
            checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
        }
957241
function onChunk(count) {
      // If chunk read has no bytes than there is nothing left, so end a
      // collection.
      if (count === 0) return next(end)

      // Move a offset `position` with `count` towards the end unless
      // position was a `null` in which case we just keep it (`null` means
      // from a current position).
      position = position === null ? position : position + count
      // Read chunk is forwarded to a consumer that will return
      // a promise which is delivered once write is complete.
      // In a future we may switch to an approach similar to new
      // streams in node, where buffering watermarks are specified
      // via options and reads can buffer up up to that point in
      // parallel to write.
      when(next(buffer.slice(0, count), state), onDrain, onError)
    }
381099
def chunk_from_mem(self, ptr):
        
        raise NotImplementedError("%s not implemented for %s" % (self.chunk_from_mem.__func__.__name__,
                                                                 self.__class__.__name__))
1363771
@Check(CheckType.NORMAL)
	public void checkMultipleCapacityUses(SarlCapacityUses uses) {
		if (!isIgnored(REDUNDANT_CAPACITY_USE)) {
			final XtendTypeDeclaration declaringType = uses.getDeclaringType();
			if (declaringType != null) {
				final Set<String> previousCapacityUses = doGetPreviousCapacities(uses,
						declaringType.getMembers().iterator());
				int index = 0;
				for (final JvmTypeReference capacity : uses.getCapacities()) {
					if (previousCapacityUses.contains(capacity.getIdentifier())) {
						addIssue(MessageFormat.format(
								Messages.SARLValidator_79,
								capacity.getSimpleName()),
								uses,
								SARL_CAPACITY_USES__CAPACITIES,
								index,
								REDUNDANT_CAPACITY_USE,
								capacity.getSimpleName());
					} else {
						previousCapacityUses.add(capacity.getIdentifier());
					}
					++index;
				}
			}
		}
	}
1048869
private <T> ChunkData<T> chunkData(String identifier, World world, BlockPos pos)
	{
		return world != null ? chunkData(identifier, world, world.getChunkFromBlockCoords(pos)) : null;
	}
341329
function chunkLength (chunk, encoding) {
  if (!chunk) {
    return 0
  }

  return !Buffer.isBuffer(chunk)
    ? Buffer.byteLength(chunk, encoding)
    : chunk.length
}