MCPcopy Create free account
hub / github.com/TigerVNC/tigervnc / checkSpace

Method checkSpace

java/com/jcraft/jsch/Channel.java:376–417  ·  view source on GitHub ↗
(int len)

Source from the content-addressed store, hash-verified

374 return size;
375 }
376 synchronized void checkSpace(int len) throws IOException {
377 int size = freeSpace();
378 if(size<len){
379 int datasize=buffer.length-size;
380 int foo = buffer.length;
381 while((foo - datasize) < len){
382 foo*=2;
383 }
384
385 if(foo > max_buffer_size){
386 foo = max_buffer_size;
387 }
388 if((foo - datasize) < len) return;
389
390 byte[] tmp = new byte[foo];
391 if(out < in) {
392 System.arraycopy(buffer, 0, tmp, 0, buffer.length);
393 }
394 else if(in < out){
395 if(in == -1) {
396 }
397 else {
398 System.arraycopy(buffer, 0, tmp, 0, in);
399 System.arraycopy(buffer, out,
400 tmp, tmp.length-(buffer.length-out),
401 (buffer.length-out));
402 out = tmp.length-(buffer.length-out);
403 }
404 }
405 else if(in == out){
406 System.arraycopy(buffer, 0, tmp, 0, buffer.length);
407 in=buffer.length;
408 }
409 buffer=tmp;
410 }
411 else if(buffer.length == size && size > BUFFER_SIZE) {
412 int i = size/2;
413 if(i<BUFFER_SIZE) i = BUFFER_SIZE;
414 byte[] tmp = new byte[i];
415 buffer=tmp;
416 }
417 }
418 }
419 void setLocalWindowSizeMax(int foo){ this.lwsize_max=foo; }
420 void setLocalWindowSize(int foo){ this.lwsize=foo; }

Callers 1

writeMethod · 0.80

Calls 1

freeSpaceMethod · 0.95

Tested by

no test coverage detected