For internal, see _remove_buffers
356167
def _separate_buffers(substate, path, buffer_paths, buffers):
    """"""
    # remove binary types from dicts and lists, but keep track of their paths
    # any part of the dict/list that needs modification will be cloned, so the original stays untouched
    # e.g. {'x': {'ar': ar}, 'y': [ar2, ar3]}, where ar/ar2/ar3 are binary types
    # will result in {'x': {}, 'y': [None, None]}, [ar, ar2, ar3], [['x', 'ar'], ['y', 0], ['y', 1]]
    # instead of removing elements from the list, this will make replacing the buffers on the js side much easier
    if isinstance(substate, (list, tuple)):
        is_cloned = False
        for i, v in enumerate(substate):
            if isinstance(v, _binary_types):
                if not is_cloned:
                    substate = list(substate) # shallow clone list/tuple
                    is_cloned = True
                substate[i] = None
                buffers.append(v)
                buffer_paths.append(path + [i])
            elif isinstance(v, (dict, list, tuple)):
                vnew = _separate_buffers(v, path + [i], buffer_paths, buffers)
                if v is not vnew: # only assign when value changed
                    if not is_cloned:
                        substate = list(substate) # clone list/tuple
                        is_cloned = True
                    substate[i] = vnew
    elif isinstance(substate, dict):
        is_cloned = False
        for k, v in substate.items():
            if isinstance(v, _binary_types):
                if not is_cloned:
                    substate = dict(substate) # shallow clone dict
                    is_cloned = True
                del substate[k]
                buffers.append(v)
                buffer_paths.append(path + [k])
            elif isinstance(v, (dict, list, tuple)):
                vnew = _separate_buffers(v, path + [k], buffer_paths, buffers)
                if v is not vnew: # only assign when value changed
                    if not is_cloned:
                        substate = dict(substate) # clone list/tuple
                        is_cloned = True
                    substate[k] = vnew
    else:
        raise ValueError("expected state to be a list or dict, not %r" % substate)
    return substate
587925
function(){
    var gl = this.gl;
    gl.deleteFramebuffer( this.fbo );
    
    for (var i = 0; i < this.attachmentsList.length; i++) {
      this.attachmentsList[i].dispose();
    }
    this.attachmentsList = null;
    this.attachments     = null;

    this.valid = false;
    this.fbo   = null;
    this.gl    = null;
  }
124095
public void clear(int i) {
        char ch = (char) -1;
        int apos = i - 1;
        int rpos = pos - 1;
        for (; rpos > -1 && apos > -1; rpos--, apos--) {
            buffer[rpos] = ch;
            buffer2[rpos] = -1;
        }
        for (rpos = buffer.length - 1; apos > -1; rpos--, apos--) {
            buffer[rpos] = ch;
            buffer2[rpos] = -1;
        }
    }
454167
def flush_buffers(self):
    """"""
    while True:
      try:
        self.read(FLUSH_READ_SIZE, timeout_ms=10)
      except usb_exceptions.LibusbWrappingError as exception:
        if exception.is_timeout():
          break
        raise
1120123
private static void free(ByteBuffer buf) {
        Cleaner cleaner = ((DirectBuffer)buf).cleaner();
        if (cleaner != null) {
            cleaner.clean();
        }
    }
1253754
private void clearBuffers() {
        // simply null out the parse buffers list, then release all the created buffers
        final boolean bTrace = TraceComponent.isAnyTracingEnabled();
        for (int i = 0; i <= this.parseIndex; i++) {
            if (bTrace && tc.isDebugEnabled()) {
                Tr.debug(tc, "Removing reference to parse buffer: " + this.parseBuffers[i]);
            }
            this.parseBuffers[i] = null;
            this.parseBuffersStartPos[i] = HeaderStorage.NOTSET;
        }
        this.parseIndex = HeaderStorage.NOTSET;
        for (int i = 0; i <= this.createdIndex; i++) {
            if (bTrace && tc.isDebugEnabled()) {
                Tr.debug(tc, "Releasing marshall buffer: " + this.myCreatedBuffers[i]);
            }
            this.myCreatedBuffers[i].release();
            this.myCreatedBuffers[i] = null;
        }
        this.createdIndex = HeaderStorage.NOTSET;
    }
96454
public void clearInvalidationBuffers() {
        this.htod.invalidationBuffer.clear(HTODInvalidationBuffer.EXPLICIT_BUFFER); // 3821 NK begin
        this.htod.invalidationBuffer.clear(HTODInvalidationBuffer.SCAN_BUFFER);
        if (this.evictionPolicy != CacheConfig.EVICTION_NONE) {
            this.htod.invalidationBuffer.clear(HTODInvalidationBuffer.GC_BUFFER); // 3821 NK end
        }
    }
1355412
def _cleanup(self, ref):
        ''
        self.transitor_states[self._weakref_holder[ref]] -= 1
        del self._weakref_holder[ref]
1041745
def _rebuffer(self):
        
        # collect a stride worth of results(result lists) or exceptions
        results = []
        exceptions = []
        for i in xrange(self.stride):
            try:
                results.append(self.iterable.next())
                exceptions.append(False)
            except Exception, excp:
                results.append(excp)
                exceptions.append(True)
        # un-roll the result lists
        res_exc = []
        for rep in xrange(self.n):
            flat_results = []
            for i in xrange(self.stride):
                result_list, exception = results[i], exceptions[i]
                if not exception:
                    flat_results.append(result_list[rep])
                else:
                    flat_results.append(result_list)
            res_exc.append((flat_results, exceptions))
        # make an iterator (like repeat)
        self._repeat_buffer = iter(res_exc)
605215
public void clear() {
        if (buffer.size() > 0) {
            terminal.format("\r%s", CURSOR_ERASE);
            for (int i = 1; i < buffer.size(); ++i) {
                terminal.format("%s%s", UP, CURSOR_ERASE);
            }
            buffer.clear();
        }
    }
613336
public function trim()
    {
        if (!isset($this->buffer[$this->bufferPos])) {
            $this->buffer = '';
        } else {
            $this->buffer = \substr($this->buffer, $this->bufferPos);
        }
        $this->bufferPos = 0;
    }
1030307
private void cleanupProcess(LinuxProcess linuxProcess, int stdinFd, int stdoutFd, int stderrFd)
   {
      pidToProcessMap.remove(linuxProcess.getPid());
      fildesToProcessMap.remove(stdinFd);
      fildesToProcessMap.remove(stdoutFd);
      fildesToProcessMap.remove(stderrFd);

      //        linuxProcess.close(linuxProcess.getStdin());
      //        linuxProcess.close(linuxProcess.getStdout());
      //        linuxProcess.close(linuxProcess.getStderr());

      if (linuxProcess.cleanlyExitedBeforeProcess.get()) {
         linuxProcess.onExit(0);
         return;
      }

      IntByReference ret = new IntByReference();
      int rc = LibC.waitpid(linuxProcess.getPid(), ret, LibC.WNOHANG);

      if (rc == 0) {
         deadPool.add(linuxProcess);
      }
      else if (rc < 0) {
         linuxProcess.onExit((Native.getLastError() == LibC.ECHILD) ? Integer.MAX_VALUE : Integer.MIN_VALUE);
      }
      else {
         handleExit(linuxProcess, ret.getValue());
      }
   }
1140368
private void internalRemove(int index)
    {
        int moving = size - index - 1;
        if (moving > 0)
            System.arraycopy(cells, index + 1, cells, index, moving);
        cells[--size] = null;
    }
1317676
def _trim_buffer_garbage(rawmessage, debug=True):
    
    while rawmessage and rawmessage[0] != MESSAGE_START_CODE_0X02:
        if debug:
            _LOGGER.debug('Buffer content: %s', binascii.hexlify(rawmessage))
            _LOGGER.debug('Trimming leading buffer garbage')
        rawmessage = rawmessage[1:]
    return rawmessage
149144
def pop_discard_buffer
      raise Shells::NotRunning unless running?
      # a standard pop discarding current data and retrieving the history.
      debug 'Discarding buffer <<'
      sync do
        hist_stdout, hist_stderr, hist_output = (output_stack.pop || [])
        self.stdout = hist_stdout || ''
        self.stderr = hist_stderr || ''
        self.output = hist_output || ''
      end
    end
172577
public static void freeDirectNoCleaner(ByteBuffer buffer) {
        assert USE_DIRECT_BUFFER_NO_CLEANER;

        int capacity = buffer.capacity();
        PlatformDependent0.freeMemory(PlatformDependent0.directBufferAddress(buffer));
        decrementMemoryCounter(capacity);
    }
762945
def _cleanup(self, kill, verbose):
        
        if kill:
            removed_indices = self.g.prune()

            self.nout -= len(removed_indices)

            if verbose and removed_indices:
                print('Removing %s' % removed_indices)

            for j in removed_indices:
                self.inv_map.pop(j[0])