Browse Source

make sure buffer_get tries to get all the bytes it was asked for

master
Felix von Leitner 16 years ago
parent
commit
e407310547
  1. 19
      buffer/buffer_get.c

19
buffer/buffer_get.c

@ -2,11 +2,18 @@
#include "buffer.h"
int buffer_get(buffer* b,char* x,unsigned long int len) {
unsigned long done;
int blen;
if ((blen=buffer_feed(b))<0) return blen;
if ((unsigned long int) blen>=len)
blen=len;
byte_copy(x,blen,b->x+b->p);
b->p+=blen;
return blen;
done=0;
while (len) {
if ((blen=buffer_feed(b))<=0) return blen;
if ((unsigned long int) blen>=len)
blen=len;
byte_copy(x,blen,b->x+b->p);
b->p+=blen;
len-=blen;
x+=blen;
done+=blen;
}
return done;
}

Loading…
Cancel
Save